Close

Jira automation rule when pull request is merged

Kev Zettler Headshot
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.

Step 1 in adding an automation in Jira on Jira project page

Search for and select the Pull request merged action. This rule executes when a pull request is merged in GitLab.

Step 2 in adding an automation using Jira

Step 2. Add a JQL condition component

Next, add a JQL condition component to the rule. Find and select the JQL condition. 

Jira automation rule to transition issues step 2: 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.

Jira automation rule to transition issues Step 2: Add a JQL condition component, write a JQL query and saving it

Step 3. Add a Transition Issue action

Now we will transition the issue to Done. Search for and select the Transition Issue action.

Jira automation rule to transition issues Step 3

Configure the Transition Issue action to set the issue status to DONE.

Jira automation rule to transition issues Step 3 Add a Transition Issue action

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.

Jira automation rule to transition issues Step 4: add an action that sends an email to stakeholders

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.

Jira automation rule to transition issues Step 4: Add Send Email action

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:

Transition to done on pull request merge: The final rule summary

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.

Kev Zettler
Kev Zettler

Kev is a lead full stack web developer and serial entrepreneur with over a decade of experience building products and teams with agile methodologies. He is a passionate contributor, author, and educator on emerging open source technologies like DevOps, cryptocurrency, and VR/AR. In his free time, he participates in indie game development jams.


Share this article

Recommended reading

Bookmark these resources to learn about types of DevOps teams, or for ongoing updates about DevOps at Atlassian.

Devops illustration

DevOps community

Devops illustration

DevOps learning path

Map illustration

Get started for free

Sign up for our DevOps newsletter

Thank you for signing up