Close

Jira automation rule when pull request is merged

Kev Zettler Headshot
Kev Zettler

Full stack web developer, DevOps

This guide demonstrates how to create a Jira and GitLab automation rule that automates pull request approvals.

It requires that you have a GitLab account and an active Jira project with the GitLab app installed and configured. Note that GitLab refers to these as “merge requests”, but the automation rule exists in Jira, where they are called “pull requests”.

Step 1. Add automation

On your Jira projects page, click the Add automation button and select the Branch, commit or pull requests automation.

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

Step 2. Add a trigger

In the New trigger list, search for and select the Pull request created trigger. Since there is no configuration needed for this trigger, click the Save button to continue.

Step 2 in adding an automation using Jira

Step 3. Add a comment

Next, add an action to the rule that leaves a comment on the issue. Search for and select the Comment on issue action from the list. Configure it with a comment message. In the comment message, smart values allows you to access and manipulate data. In the following example, smart values are used to populate the pull request title and URL. 

Be sure that “Prevent duplicates” is checked. This helps prevent the rule from spamming the issue with duplicate comments. Once you have a comment message configured, click Save.

Screenshot of adding a comment onto an issue

Step 4. Add a condition

Next, add a condition to the rule so that it targets “In Progress” issues. Search for and add Issue fields condition to the rule. Configure the condition so the status field equals “in progress”. Click Save.

Screenshot of issue fields condition

Step 5. Transition the issue

Next, transition the issue to “In Review”. Add a new action component and search for and select the Transition issue action.

Adding component of "transit" to issue

Configure the Transition issue action so it updates the issue status to “In Review”. Once configured, click Save.

Adding "in review" to transition issue

The final rule summary should look like:

Rule details: summary of all changes

When a pull request is created, comment on the attached issue. If the status is “In Progress”, move it to “In Review”. This helps keep Jira issues updated when developers actively work on issues. Enter a name for the automation rule and click Turn it on to activate. 

Once activated, trigger this rule by creating a Jira issue and push a commit to GitLab that references that commit. Visit the automation Audit log to review the rule’s behaviour or debug any errors.

This rule is a good foundational rule for other advanced pull request rules. Be sure to check out hundreds of other rules in our Automation Template Library.

Kev Zettler
Kev Zettler

Kev는 선임 풀스택 웹 개발자이자 계속하여 신규 기업을 만들고 있는 사업가로 애자일 방법론을 활용한 제품 및 팀 구축 부문에서 십여 년의 경력을 보유하고 있습니다. DevOps, 암호화폐 및 VR/AR 부문 등 새롭게 부상하는 오픈소스 기술에 대한 열정적인 기여자, 저자이자 교육자이기도 합니다. 여가 시간에는 인디 게임 개발 모임에 참여합니다.


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

Simulation workshop

Map illustration

Get started for free

Sign up for our DevOps newsletter

Thank you for signing up