Articles
Tutorials
Interactive Guides
Jira automation rule when pull request is merged
![Kev Zettler Headshot](https://wac-cdn.atlassian.com/dam/jcr:09c4d11b-0f74-4dcd-aeba-28b5467d8a31/Headshot-Kev%20Zettler@2x.png?cdnVersion=2567)
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](https://wac-cdn.atlassian.com/dam/jcr:e8d705af-fa17-43ef-8179-cc9416b5d8c2/image1.png?cdnVersion=2567)
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](https://wac-cdn.atlassian.com/dam/jcr:664c319e-6cc4-402a-905c-1652e4fd0350/image2.png?cdnVersion=2567)
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.](https://wac-cdn.atlassian.com/dam/jcr:f9210cd3-13bd-48f6-b2ef-019830d2a70f/image3.png?cdnVersion=2567)
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](https://wac-cdn.atlassian.com/dam/jcr:849a0ae1-e693-4d78-8e80-b15f385ee1b7/image4.png?cdnVersion=2567)
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](https://wac-cdn.atlassian.com/dam/jcr:e8d705af-fa17-43ef-8179-cc9416b5d8c2/image1.png?cdnVersion=2567)
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](https://wac-cdn.atlassian.com/dam/jcr:a0b05fe0-9fff-40a0-bc29-b94c4e4774ee/image6.png?cdnVersion=2567)
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](https://wac-cdn.atlassian.com/dam/jcr:ef506c65-7e2b-4f0f-96d9-335f4d81d53e/image7.png?cdnVersion=2567)
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](https://wac-cdn.atlassian.com/dam/jcr:295f98e7-d512-4c0b-8709-9ddaf14e001f/image8.png?cdnVersion=2567)
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](https://wac-cdn.atlassian.com/dam/jcr:295f98e7-d512-4c0b-8709-9ddaf14e001f/image8.png?cdnVersion=2567)
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.
![Devops illustration](https://wac-cdn.atlassian.com/dam/jcr:bd9d8b2c-ca36-444f-8595-719cb1990e64/Devops-community.png?cdnVersion=2567)
DevOps community
![Devops illustration](https://wac-cdn.atlassian.com/dam/jcr:297108ea-d232-4368-af51-b53af230c4fe/Simulation-workshop.png?cdnVersion=2567)
DevOps learning path
![Map illustration](https://wac-cdn.atlassian.com/dam/jcr:25f6330a-4191-408f-a4e5-2e24bfba67b4/Maturity-model.png?cdnVersion=2567)