Report a Jira bug from a New Relic alert
Overviewโ
This guide will help you implement a self-service action in Port that allows you to report bugs in Jira based on New Relic alert in one click, ensuring prompt issue resolution and improving overall platform reliability.
You can implement this action in two ways:
- Synced webhooks: A simpler approach that directly interacts with Jira's API through Port, ideal for quick implementation and minimal setup.
- GitHub workflow: A more flexible approach that allows for complex workflows and custom logic, suitable for teams that want to maintain their automation in Git.
Prerequisitesโ
- Complete the onboarding process.
- Access to your Jira organization with permissions to create issues.
- Port's GitHub app installed (required for GitHub Actions implementation).
- Jira API token with permissions to create new issues.
Set up data modelโ
If you have installed Port's Jira integration and New Relic integration, the relevant blueprints will be automatically created in your portal.
If you chose not to install the integrations, you will need to create the blueprints manually:
Create the jira issue blueprint
-
Go to your Builder page.
-
Click on
+ Blueprint
. -
Click on the
{...}
button in the top right corner, and choose "Edit JSON". -
Add this JSON schema:
Jira Issue Blueprint (Click to expand)
{
"identifier": "jiraIssue",
"title": "Jira Issue",
"icon": "Jira",
"schema": {
"properties": {
"url": {
"title": "Issue URL",
"type": "string",
"format": "url",
"description": "URL to the issue in Jira"
},
"status": {
"title": "Status",
"type": "string",
"description": "The status of the issue"
},
"issueType": {
"title": "Type",
"type": "string",
"description": "The type of the issue"
},
"components": {
"title": "Components",
"type": "array",
"description": "The components related to this issue"
},
"assignee": {
"title": "Assignee",
"type": "string",
"format": "user",
"description": "The user assigned to the issue"
},
"reporter": {
"title": "Reporter",
"type": "string",
"description": "The user that reported to the issue",
"format": "user"
},
"priority": {
"title": "Priority",
"type": "string",
"description": "The priority of the issue"
},
"created": {
"title": "Created At",
"type": "string",
"description": "The created datetime of the issue",
"format": "date-time"
},
"updated": {
"title": "Updated At",
"type": "string",
"description": "The updated datetime of the issue",
"format": "date-time"
}
}
},
"calculationProperties": {},
"relations": {}
} -
Click "Save" to create the blueprint.
Create the New Relic Alert blueprint
-
Go to your Builder page.
-
Click on
+ Blueprint
. -
Click on the
{...}
button in the top right corner, and choose "Edit JSON". -
Add this JSON schema:
New Relic Alert Blueprint (Click to expand)
{
"identifier": "newRelicAlert",
"description": "This blueprint represents a New Relic alert in our software catalog",
"title": "New Relic Alert",
"icon": "NewRelic",
"ownership": {
"type": "Inherited",
"title": "Owning Teams",
"path": "alert_to_workload.service"
},
"schema": {
"properties": {
"priority": {
"type": "string",
"title": "Priority",
"enum": [
"CRITICAL",
"HIGH",
"MEDIUM",
"LOW"
],
"enumColors": {
"CRITICAL": "red",
"HIGH": "red",
"MEDIUM": "yellow",
"LOW": "green"
}
},
"state": {
"type": "string",
"title": "State",
"enum": [
"ACTIVATED",
"CLOSED",
"CREATED"
],
"enumColors": {
"ACTIVATED": "yellow",
"CLOSED": "green",
"CREATED": "lightGray"
}
},
"sources": {
"type": "array",
"items": {
"type": "string"
},
"title": "Sources"
},
"alertPolicyNames": {
"type": "array",
"items": {
"type": "string"
},
"title": "Alert Policy Names"
},
"conditionName": {
"type": "array",
"items": {
"type": "string"
},
"title": "Condition Name"
},
"link": {
"type": "string",
"title": "Link",
"format": "url"
},
"description": {
"type": "string",
"title": "Description"
},
"activatedAt": {
"type": "string",
"title": "Activated at",
"format": "date-time"
}
},
"required": []
},
"mirrorProperties": {
"cloud_resource_name": {
"title": "Cloud Resource",
"path": "cloud_resource.$title"
},
"port_service": {
"title": "Service",
"path": "alert_to_workload.service.$title"
},
"team": {
"title": "Team",
"path": "alert_to_workload.service.$team"
},
"workload_name": {
"title": "Workload name",
"path": "alert_to_workload.$title"
},
"pager_duty_service": {
"title": "Pager duty service",
"path": "alert_to_workload.service.pager_duty_service.$identifier"
}
},
"calculationProperties": {},
"aggregationProperties": {},
"relations": {
"alert_to_workload": {
"title": "Workload",
"target": "workload",
"required": false,
"many": false
},
"cloud_resource": {
"title": "Cloud resource",
"target": "newRelicCloudResource",
"required": false,
"many": false
}
}
} -
Click "Save" to create the blueprint.
Implementationโ
- Synced webhook
- GitHub workflow
You can create Jira bugs by leveraging Port's synced webhooks and secrets to directly interact with the Jira's API. This method simplifies the setup by handling everything within Port.
Add Port secrets
If you have already installed Port's Jira integration, these secrets should already exist in your portal.
To view your existing secrets:
- Click on the
...
button in the top right corner of your Port application. - Choose Credentials, then click on the
Secrets
tab.
To add these secrets to your portal:
-
Click on the
...
button in the top right corner of your Port application. -
Click on Credentials.
-
Click on the
Secrets
tab. -
Click on
+ Secret
and add the following secrets:-
JIRA_API_TOKEN
- Your Jira API token -
JIRA_USER_EMAIL
- The email of the Jira user that owns the API token -
JIRA_AUTH
- Base64 encoded string of your Jira credentials. Generate this by running:echo -n "your-email@domain.com:your-api-token" | base64
Replace
your-email@domain.com
with your Jira email andyour-api-token
with your Jira API token.One time generationThe base64 encoded string only needs to be generated once and will work for all webhook calls until you change your API token.
-
Set up self-service action
Follow these steps to create the self-service action:
-
Head to the self-service page.
-
Click on the
+ New Action
button. -
Click on the
{...} Edit JSON
button. -
Copy and paste the following JSON configuration into the editor.
Report a bug from New Relic alert action (Webhook) (Click to expand)
{
"identifier": "report_a_jira_bug_from_new_relic_alert",
"title": "Report a bug from New Relic alert (Webhook)",
"icon": "Jira",
"description": "Report a Jira bug in Port based on a New Relic alert.",
"trigger": {
"type": "self-service",
"operation": "DAY-2",
"userInputs": {
"properties": {
"project": {
"title": "Project",
"description": "The Jira project where the bug will be created",
"icon": "Jira",
"type": "string",
"blueprint": "jiraProject",
"format": "entity"
}
},
"required": [
"project"
],
"order": [
"project"
]
},
"blueprintIdentifier": "newRelicAlert"
},
"invocationMethod": {
"type": "WEBHOOK",
"url": "https://<JIRA_ORGANIZATION_URL>.atlassian.net/rest/api/3/issue",
"agent": false,
"synchronized": true,
"method": "POST",
"headers": {
"Authorization": "Basic {{.secrets.JIRA_AUTH}}",
"Content-Type": "application/json"
},
"body": {
"fields": {
"project": {
"key": "{{.inputs.project.identifier}}"
},
"summary": "Bug | New Relic | {{.entity.title}}",
"description": {
"version": 1,
"type": "doc",
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "\n New Relic description: {{.entity.description}}\n\n New Relic link: {{.entity.link}}"
}
]
},
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "Reported by: {{.trigger.by.user.email}}"
}
]
}
]
},
"issuetype": {
"name": "Bug"
}
}
}
},
"requiredApproval": false
} -
Click
Save
.
Replace <JIRA_ORGANIZATION_URL>
in the webhook URL with your Jira organization URL (e.g., example.atlassian.net
).
Now you should see the Report a bug from New Relic alert
action in the self-service page. ๐
To implement this use-case using a GitHub workflow, follow these steps:
Add GitHub secrets
In your GitHub repository, go to Settings > Secrets and add the following secrets:
JIRA_API_TOKEN
- Jira API token generated by the user.JIRA_BASE_URL
- The URL of your Jira organization. For example, https://your-organization.atlassian.net.JIRA_USER_EMAIL
- The email of the Jira user that owns the Jira API token.PORT_CLIENT_ID
- Your portclient id
How to get the credentials.PORT_CLIENT_SECRET
- Your portclient secret
How to get the credentials.
Add GitHub workflow
Create the file .github/workflows/report-a-bug.yml
in the .github/workflows
folder of your repository.
We recommend creating a dedicated repository for the workflows that are used by Port actions.
GitHub Workflow (Click to expand)
name: Report a bug in jira
on:
workflow_dispatch:
inputs:
project:
required: true
type: string
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: ${{ inputs.project }}
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: ${{ secrets.JIRA_BASE_URL }}/browse/${{ steps.create.outputs.issue }}
runId: ${{ fromJson(inputs.port_context).run_id }}
logMessage: |
Jira issue with ID ${{ steps.create.outputs.issue }} created! โ
Set up self-service action
We will create a self-service action to handle creating bugs in Jira. To create a self-service action follow these steps:
-
Head to the self-service page.
-
Click on the
+ New Action
button. -
Click on the
{...} Edit JSON
button. -
Copy and paste the following JSON configuration into the editor.
Report a bug action (Click to expand)
Modification RequiredMake sure to replace
<GITHUB_ORG>
and<GITHUB_REPO>
with your GitHub organization and repository names respectively.{
"identifier": "jiraIssue_report_a_bug_from_newrelic",
"title": "Report a bug from New Relic (GitHub actions)",
"icon": "Jira",
"description": "Report a bug in Port from a New Relic alert.",
"trigger": {
"type": "self-service",
"operation": "DAY-2",
"userInputs": {
"properties": {
"project": {
"title": "Project",
"description": "The Jira project where the bug will be created",
"icon": "Jira",
"type": "string",
"blueprint": "jiraProject",
"format": "entity"
}
},
"required": [
"project"
],
"order": [
"project"
]
},
"blueprintIdentifier": "newRelicAlert"
},
"invocationMethod": {
"type": "GITHUB",
"org": "<GITHUB_ORG>",
"repo": "<GITHUB_REPO>",
"workflow": "report-a-bug.yml",
"workflowInputs": {
"project": "{{.inputs.project.identifier}}",
"description": "New Relic description: {{.entity.description}}\n\n New Relic link: {{.entity.link}}\n\n Reported by: {{.trigger.by.user.email}}",
"short_title": "Bug | New Relic | {{.entity.title}}",
"port_context": {
"run_id": "{{ .run.id }}",
"triggered_by": "{{ .trigger.by.user.email }}"
}
},
"reportWorkflowStatus": true
},
"requiredApproval": false
} -
Click
Save
.
Now you should see the Report a bug from New Relic (gitHub actions)
action in the self-service page. ๐
Let's test it!โ
-
Head to the self-service page of your portal
-
Choose either the GitHub workflow or webhook implementation:
- For webhook: Click on
Report a bug from New Relic alert (Webhook)
- For GitHub workflow: Click on
Report a bug from New Relic alert (GitHub actions)
- For webhook: Click on
-
Fill in the bug details:
- Select the New Relic alert that will trigger the creation of the Jira bug
- Select the Jira project where the bug will be created
-
Click on
Execute
-
Done! wait for the bug to be created in Jira