Skip to main content

Check out Port for yourselfย 

Open Jira issue with automatic label

This self-service action shows how to create a Jira issue with a label that links the issue to a concerned service in Port.

Use casesโ€‹

  • Categorize tasks, issues and bugs by services directly from Port
  • Add service metadata to issues from Port

Prerequisitesโ€‹

  1. Port's GitHub app needs to be installed

  2. Jira API token with permissions to create new issues

  3. In your GitHub repository, go to Settings > Secrets and add the following secrets:

  4. Optional - Install Port's Jira integration learn more

Jira integration

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. In case you decided not to install the Jira integration, you will need to create a blueprint for the Jira Issue in Port.
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"
},
"creator": {
"title": "Creator",
"type": "string",
"description": "The user that created to the issue",
"format": "user"
},
"priority": {
"title": "Priority",
"type": "string",
"description": "The priority of the issue"
},
"labels": {
"items": {
"type": "string"
},
"title": "Labels",
"type": "array"
},
"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": {
"parentIssue": {
"target": "jiraIssue",
"title": "Parent Issue",
"required": false,
"many": false
},
"subtasks": {
"target": "jiraIssue",
"title": "Subtasks",
"required": false,
"many": true
}
}
}
  1. You have finished the onboarding process and created a Service blueprint from the onboarding steps. You can alternatively create the Service blueprint in Port using the schema below:
Service Blueprint (Click to expand)
{
"identifier": "service",
"title": "Service",
"icon": "Github",
"schema": {
"properties": {
"readme": {
"title": "README",
"type": "string",
"format": "markdown",
"icon": "Book"
},
"url": {
"title": "URL",
"format": "url",
"type": "string",
"icon": "Link"
},
"language": {
"icon": "Git",
"type": "string",
"title": "Language",
"enum": [
"GO",
"Python",
"Node",
"React"
],
"enumColors": {
"GO": "red",
"Python": "green",
"Node": "blue",
"React": "yellow"
}
},
"slack": {
"icon": "Slack",
"type": "string",
"title": "Slack",
"format": "url"
},
"code_owners": {
"title": "Code owners",
"description": "This service's code owners",
"type": "string",
"icon": "TwoUsers"
},
"type": {
"title": "Type",
"description": "This service's type",
"type": "string",
"enum": [
"Backend",
"Frontend",
"Library"
],
"enumColors": {
"Backend": "purple",
"Frontend": "pink",
"Library": "green"
},
"icon": "DefaultProperty"
},
"lifecycle": {
"title": "Lifecycle",
"type": "string",
"enum": [
"Production",
"Experimental",
"Deprecated"
],
"enumColors": {
"Production": "green",
"Experimental": "yellow",
"Deprecated": "red"
},
"icon": "DefaultProperty"
},
"locked_in_prod": {
"icon": "DefaultProperty",
"title": "Locked in Prod",
"type": "boolean",
"default": false
},
"locked_reason_prod": {
"icon": "DefaultProperty",
"title": "Locked Reason Prod",
"type": "string"
}
},
"required": []
},
"mirrorProperties": {},
"calculationProperties": {},
"aggregationProperties": {},
"relations": {}
}

GitHub Workflowโ€‹

Create the file open-jira-issue-with-automatic-label.yml in the .github/workflows folder of your repository and copy the content of the workflow configuration below:

Dedicated repository

We recommend creating a dedicated repository for the workflows that are used by Port actions.

Open Jira issue with automatic label workflow (Click to expand)
name: Open Jira issue with automatic label
on:
workflow_dispatch:
inputs:
title:
required: true
type: string
type:
required: true
type: string
project:
required: true
type: string
port_context:
required: true
type: string

jobs:
create-entity-in-port-and-update-run:
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 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 with automatic label.. โ›ด๏ธ

- name: Create Jira issue
id: create
uses: atlassian/gajira-create@v3
with:
project: ${{ inputs.project }}
issuetype: ${{ inputs.type }}
summary: ${{ inputs.title }}
fields: |
${{ fromJson(inputs.port_context).entity != null
&& format('{{ "labels": ["port-{0}"] }}', fromJson(inputs.port_context).entity)
|| '{}'
}}

- 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 created! โœ…
The issue id is: ${{ steps.create.outputs.issue }}

Port Configurationโ€‹

On the self-service page, create the Port action against the Service blueprint. This will trigger the GitHub workflow.

Open Jira Issue with automatic label action (Click to expand)
Modification Required

Make sure to replace <GITHUB_ORG> and <GITHUB_REPO> with your GitHub organization and repository names respectively

{
"identifier": "service_open_jira_issue_with_automatic_label",
"title": "Open Jira Issue with automatic label",
"icon": "Jira",
"description": "Creates a Jira issue with a label to the concerned service.",
"trigger": {
"type": "self-service",
"operation": "DAY-2",
"userInputs": {
"properties": {
"title": {
"title": "Title",
"description": "Title of the Jira issue",
"icon": "Jira",
"type": "string"
},
"type": {
"title": "Type",
"description": "Issue type",
"icon": "Jira",
"type": "string",
"default": "Task",
"enum": [
"Task",
"Story",
"Bug",
"Epic"
],
"enumColors": {
"Task": "blue",
"Story": "green",
"Bug": "red",
"Epic": "pink"
}
},
"project": {
"title": "Project",
"description": "The issue will be created on this project",
"icon": "Jira",
"type": "string",
"blueprint": "jiraProject",
"format": "entity"
}
},
"required": [
"title",
"type",
"project"
],
"order": [
"title",
"type"
]
},
"blueprintIdentifier": "service"
},
"invocationMethod": {
"type": "GITHUB",
"org": "<Enter GitHub organization>",
"repo": "<Enter GitHub repository>",
"workflow": "open-jira-issue-with-automatic-label.yml",
"workflowInputs": {
"title": "{{.inputs.\"title\"}}",
"type": "{{.inputs.\"type\"}}",
"project": "{{.inputs.\"project\" | if type == \"array\" then map(.identifier) else .identifier end}}",
"port_context": {
"entity": "{{.entity.identifier}}",
"run_id": "{{.run.id}}"
}
},
"reportWorkflowStatus": true
},
"requiredApproval": false,
"publish": true
}

Let's test itโ€‹

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

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

Congrats ๐ŸŽ‰ You've created your first Jira issue with an automatic label that links to the service in Port!