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.

Time

10 minute read.

Audience

You’re an experienced user of Jira Software and have a GitLab account.

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 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 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