Automatically Link PRs to Related Jira Issues
Provide automatic links to Jira issues that are associated with PRs.
Configuration Description
Conditions (all must be true):
- The PR contains a reference to an Jira card in the title or branch name.
Automation Actions:
- Post a comment that provides a link to the associated Jira Card.
Automatically Link to the Related Jira Card
# -*- mode: yaml -*-
manifest:
version: 1.0
provider: jira
# Change this to the name of your Jira organization
orgName: org
{% set ticketid = "" %}
{% for ticket in tickets %}
{% if (ticket | includes(regex=r/.+/)) %}
{% set ticketid = ticket %}
{% endif %}
{% endfor %}
automations:
link_jira:
if:
- {{ has.ticket_in_title or has.ticket_in_branch }}
run:
- action: add-comment@v1
args:
comment: Issue Tracker Link - [{{ticketid}}]({{tracker[provider].baseurl}}{{ticketid}})
has:
ticket_in_title: {{ pr.title | includes(regex=tracker[provider].pattern) }}
ticket_in_branch: {{ branch.name | includes(regex=tracker[provider].pattern) }}
tracker:
jira:
baseurl: https://[orgName].atlassian.net/browse/
pattern: r/\b[A-Za-z]+-\d+\b/
tickets:
- {{branch.name | capture(regex=tracker[provider].pattern)}}
- {{pr.title | capture(regex=tracker[provider].pattern)}}
Additional Resources
gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.
Learn More about how gitStream Works.
Related Automations:
- Estimate the amount of time it would require someone to complete a PR review.
- Flag missing Jira ticket information
- Label PRs that delete files.
- Label PRs that lack tests
- Provide information about what percent of a PR is new code.
- Request PR authors to provide screenshots in relevant PRs.
More Automations can be found on the Automation Library and Integrations pages.