Jira automation rule when pull request is merged
This guide demonstrates how to create a Jira and GitLab automation rule that automates pull request approvals.
10 minute read.
You’re an experienced user of Jira Software and have a GitLab account.
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 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 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.
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.
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.
Configure the Transition issue action so it updates the issue status to “In Review”. Once configured, click Save.
The final rule summary should look like:
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.
Share this article
Bookmark these resources to learn about types of DevOps teams, or for ongoing updates about DevOps at Atlassian.