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 是领先的全栈 Web 开发人员和连续创业者,拥有十多年使用敏捷方法构建产品和团队的经验。他是 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