Articles
Tutorials
Interactive Guides
Jira automation rule when pull request is merged
Kev Zettler
Full stack web developer, DevOps
This guide details how to create a Jira automation rule that transitions an issue to done and notifies stakeholders by email when a pull request is merged.
Time
5 minute read.
Audience
You’re an experienced user of Jira Software and GitLab.
Prerequisites
You are an existing GitLab customer. Get the GitLab for Jira integration here.
If you’re new to GitLab, get started here.
You have an active Jira project with the GitLab application installed and configured. Get started with Jira here.
Step 1. Add automation
On your Jira project page, click the add automation button. Then, select the Branch, commit or pull requests option.
Search for and select the Pull request merged action. This rule executes when a pull request is merged in GitLab.
Step 2. Add a JQL condition component
Next, add a JQL condition component to the rule. Find and select the JQL condition.
Configure the JQL condition by writing a JQL query and saving it. The query is Input the query development[pullrequests].open = 0. Then,click the save button. This query to ensures that if there are other open pull requests for the issue, the issue will not transition to done.
Step 3. Add a Transition Issue action
Now we will transition the issue to Done. Search for and select the Transition Issue action.
Configure the Transition Issue action to set the issue status to DONE.
Step 4. Add Send Email action
Next, add an action that sends an email to stakeholders notifying them that the pull request was merged. Find and select the Send Email action.
Now we will configure the Send Email action so that it sends to some relevant email addresses with template data that is populated from the pull request. The values we used in the email content that are surrounded by parentheses are smart values. The smart value {{pullRequest.title}} is used to populate the title and {{pullRequest.url}} to include the URL from the pull request. Learn more about smart values. When you have configured the send email action click the Save button to continue.
Go ahead and enter a name for this rule and click the Turn It on button.
The final rule summary should look similar to the following:
You can now trigger this rule by creating a Jira issue and referencing the issue in a merged pull request. Visit the Audit Log to review its behavior and diagnose any errors. For future reference building other rules check out hundreds of other rules in our Automation Template Library.
Share this article
Next Topic
Recommended reading
Bookmark these resources to learn about types of DevOps teams, or for ongoing updates about DevOps at Atlassian.