Skip to main content

Report a bug

Overview

An example of creating a Jira bug from Port using Port's self service actions.

Prerequisites

Steps

  1. Create the following GitHub action secrets
  1. Optional - Install Port's Jira integration learn more
Blueprint

This step is not required for this example, but it will create all the blueprint boilerplate for you, and also update the catalog in real time with the new issue created.

  1. Creating the action in Port
Action usage

You can add this action to the Service or Jira Issue blueprints

Report a bug (Click to expand)
{
"identifier": "jiraIssue_report_a_bug",
"title": "Report a bug",
"icon": "Jira",
"description": "Report a bug in Port to our product team.",
"trigger": {
"type": "self-service",
"operation": "CREATE",
"userInputs": {
"properties": {
"description": {
"icon": "DefaultProperty",
"title": "Description",
"type": "string"
},
"short_title": {
"icon": "DefaultProperty",
"title": "Short title",
"type": "string"
}
},
"required": [
"short_title",
"description"
],
"order": [
"short_title",
"description"
]
}
},
"invocationMethod": {
"type": "GITHUB",
"org": "<Enter GitHub organization>",
"repo": "<Enter GitHub repository>",
"workflow": "report-a-bug.yml",
"workflowInputs": {
"description": "{{.inputs.\"description\"}}",
"short_title": "{{.inputs.\"short_title\"}}",
"port_context": {
"run_id": "{{ .run.id }}",
"triggered_by": "{{ .trigger.by.user.email }}"
}
},
"reportWorkflowStatus": true
},
"requiredApproval": false,
"publish": true
}
  1. Create a workflow file under .github/workflows/report-a-bug.yaml using the workflow:
Report a bug workflow (Click to expand)
## This Workflow creates a basic jira bug and updates in Port
## Remove comments and edit for more fields as part of the jira bug

name: Report a bug in jira

on:
workflow_dispatch:
inputs:
description:
required: true
type: string
short_title:
required: true
type: string
port_context:
required: true
type: string

jobs:
create_jira_issue:
runs-on: ubuntu-latest
steps:
- name: Login
uses: atlassian/gajira-login@v3
env:
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}

- name: Inform searching of user in user list
uses: port-labs/port-github-action@v1
with:
clientId: ${{ secrets.PORT_CLIENT_ID }}
clientSecret: ${{ secrets.PORT_CLIENT_SECRET }}
operation: PATCH_RUN
runId: ${{ fromJson(inputs.port_context).run_id }}
logMessage: |
Searching for user in organization user list... ⛴️

- name: Search for reporter among user list
id: search_for_reporter
uses: fjogeleit/http-request-action@v1
with:
url: "${{ secrets.JIRA_BASE_URL }}/rest/api/3/user/search?query=${{ fromJson(inputs.port_context).triggered_by }}"
method: "GET"
username: ${{ secrets.JIRA_USER_EMAIL }}
password: ${{ secrets.JIRA_API_TOKEN }}
customHeaders: '{"Content-Type": "application/json"}'

- name: Install jq
run: sudo apt-get install jq
if: steps.search_for_reporter.outcome == 'success'

- name: Retrieve user list from search
id: user_list_from_search
if: steps.search_for_reporter.outcome == 'success'
run: |
selected_user_id=$(echo '${{ steps.search_for_reporter.outputs.response }}' | jq -r 'if length > 0 then .[0].accountId else "empty" end')
selected_user_name=$(echo '${{ steps.search_for_reporter.outputs.response }}' | jq -r 'if length > 0 then .[0].displayName else "empty" end')
echo "selected_user_id=${selected_user_id}" >> $GITHUB_OUTPUT
echo "selected_user_name=${selected_user_name}" >> $GITHUB_OUTPUT

- name: Inform user existence
if: steps.user_list_from_search.outputs.selected_user_id != 'empty'
uses: port-labs/port-github-action@v1
with:
clientId: ${{ secrets.PORT_CLIENT_ID }}
clientSecret: ${{ secrets.PORT_CLIENT_SECRET }}
operation: PATCH_RUN
runId: ${{ fromJson(inputs.port_context).run_id }}
logMessage: |
User found 🥹 Bug reporter will be ${{ steps.user_list_from_search.outputs.selected_user_name }}... ⛴️

- name: Inform user inexistence
if: steps.user_list_from_search.outputs.selected_user_id == 'empty'
uses: port-labs/port-github-action@v1
with:
clientId: ${{ secrets.PORT_CLIENT_ID }}
clientSecret: ${{ secrets.PORT_CLIENT_SECRET }}
operation: PATCH_RUN
runId: ${{ fromJson(inputs.port_context).run_id }}
logMessage: |
User not found 😭 Bug will be created with default reporter ⛴️

- name: Inform starting of jira issue creation
uses: port-labs/port-github-action@v1
with:
clientId: ${{ secrets.PORT_CLIENT_ID }}
clientSecret: ${{ secrets.PORT_CLIENT_SECRET }}
operation: PATCH_RUN
runId: ${{ fromJson(inputs.port_context).run_id }}
logMessage: |
Creating a new Jira issue.. ⛴️

- name: Create Jira issue
id: create
uses: atlassian/gajira-create@v3
with:
project: PORT
issuetype: Bug
summary: ${{inputs.short_title}}
description: |
${{inputs.description}}
fields: |-
${{ steps.user_list_from_search.outputs.selected_user_id != 'empty'
&& format('{{"reporter": {{"id": "{0}" }}}}', steps.user_list_from_search.outputs.selected_user_id)
|| '{}'
}}

- name: Inform creation of Jira issue
uses: port-labs/port-github-action@v1
with:
clientId: ${{ secrets.PORT_CLIENT_ID }}
clientSecret: ${{ secrets.PORT_CLIENT_SECRET }}
operation: PATCH_RUN
link: https://getport.atlassian.net/browse/${{ steps.create.outputs.issue }}
runId: ${{ fromJson(inputs.port_context).run_id }}
logMessage: |
Jira issue with ID ${{ steps.create.outputs.issue }} created! ✅

Control the project context

Remember to update the project name, <ENTER_JIRA_PROJECT_NAME> to your Jira project

  1. Trigger the action from Port's Self Service hub

  2. Done! wait for the bug to be created in Jira

Congrats 🎉 You've created your first bug in Jira from Port!