Transition issue when pull request is merged on a specific branch in Github

grant.stevens@thingtech.com March 8, 2019

I'm trying to figure out how to transition an issue when a developer merges a pull request that contains a Jira-linked commit. I'm trying to automate a specific part of our workflow to eliminate the need for developers to manually transition a story.

I basically need a conditional trigger on a workflow transition so I can say something like "when a pull request is merged to master that contains a related commit, transition this story".

I know that we could probably achieve this with smart commits, but that requires engineers to remember to add the proper hashtag to their commit messages for the merge branch. I want to eliminate as much human interaction as possible, so smart commits don't fit the bill.

Is there a way to script this somehow? I'm still a bit new to Jira administration, so I'm familiar with the possibilities.

Thanks!

5 answers

1 accepted

5 votes
Answer accepted
Julio Kenji Bando April 13, 2020

Hello!

I was looking for the same here then I found that it's already available in automation rules:

Jira Automation Rules 

Koen_Langenhuijzen April 14, 2020

Unfortunately this does not seem to work when using Jira Server?

Daniel Eads
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 14, 2020

Hi @Koen_Langenhuijzen - the automation rules for Server are the same, however you need to install the Automation app separately here for Jira Server and Jira Data Center  (Automation is built-in in Cloud now).

@Julio Kenji Bando this is a great use of automation!

Like Julio Kenji Bando likes this
Koen_Langenhuijzen April 15, 2020

Hi @Daniel Eads , thanks for your suggestion! However, while playing with the https://docs.automationforjira.com/rule-playground/#/ I was unable to find a trigger that is invoked when a pullrequest is merged by Bitbucket (where the branch is linked to Jira since it has been created from Jira and contains the issue key in the name).

Are you sure that this functionallity is covered? 

Looking forward for your reply!

Daniel Eads
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 15, 2020

Hey @Koen_Langenhuijzen - I've just checked the playground and indeed see that the DevOps triggers are missing. In Cloud, there are five (including the "pull request merged" that is helpful in this case):image.png

I'm working with the automation team now to get some more insight on where the Server version of Automation is at in regards to the new DevOps features that are available in Cloud currently. Hang tight!

Akilesh DS September 24, 2020

Hi @Daniel Eads 

Any update?
we seem to not have the options for Jira server.

Thanks!

Daniel Eads
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 29, 2020

Hello @Akilesh DS,

The DevOps triggers are not currently in the Jira Server variant of Automation, as of plugin version 7.2.1. We do have an open feature request to get them added to Server, which you can view, watch, and vote on here: JIRAAUTOSERVER-20 

Perrine HUVETEAU January 21, 2021

Hello 
We have Jira cloud, so we have the automation option "Pull request merged" but we are looking for a way to automate only when a PR is made to merge on a specific branch (master) on Github.

Is that in anyway possible ? 

Thanks in advance

Like # people like this
Neil Cameron March 4, 2021

+1 can't seem to specify and condition that destination branch = develop or master

Like # people like this
Miko Stefanov March 5, 2021

+1 We also need the trigger to be executed only when there is a merge on a specific target branch. I cannot find such a condition.

Like # people like this
Aron Gombas _Midori_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 9, 2021

devops-automation-rule-changeset-accepted

For Jira Server, the DevOps triggers are implemented by the Better DevOps Automation app.

The original use case can be implemented with the Commit Created trigger. It triggers its rule for every commit including the one created by a pull request and which is actually a "merge" commit.

Note that the details of the commit can accessed via the {{devops.commit}} smart value. It means that rule should contain 2 conditions:

  1. {{commit.isMerge}} == TRUE
  2. {{commit.branch}} == "master"
Neil Cameron April 12, 2021

@Aron Gombas _Midori_ can you confirm that this will work for standard jira cloud automation?

 

When I use Commit Created trigger, {{commit.isMerge}} and {{commit.branch}}  are both empty, all I have is {{commit}} which gives me the commit ID, which doesn't help.

 

Any other ideas?

Aron Gombas _Midori_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 13, 2021

@Neil Cameron According to the smart value reference in the official Atlassian documentation, {{commit.isMergeCommit}} should definitely work in Jira Cloud!

(Our solution that I wrote about above is for Jira Data Center and for Jira Server.)

Matt Goodson June 27, 2021

@Aron Gombas _Midori_ What about if we use rebase rather than merge commits?

Aron Gombas _Midori_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 28, 2021

@Matt Goodson Are you asking about "rebase on Jira Cloud" or "rebase on Jira Server or Jira Data Center"? (This thread slightly changed its original direction, that's why I want to be sure.)

Matt Goodson June 28, 2021

Jira cloud 

Matt Goodson June 28, 2021

@Aron Gombas _Midori_  Any commit included in the rebase should be able to trigger the automation for a linked issue. I assume we can't use isMergeCommit because rebase just uses the existing commits. 

As far as I can see {{commit.branch}} isn't supported on Jira Cloud which would be a suitable alternative in our case.

Aron Gombas _Midori_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 29, 2021

I'm not sure about Jira Cloud. I agree that "isMergeCommit" will not help with this use case, as rebase will not create a commit with multiple parents (i.e. a merge commit).

At the same time, {{commit.branch}} will definitely work on Jira Data Center and Jira Server with the devops automation app, but these are not your deployment platform.

10 votes
Mitch Ware October 21, 2019

@Daniel Eads We're currently using Workflow Triggers to accomplish exactly what you've explained here (via Github Enterprise) and its working very well - statuses transition as we expect them to when an associated pull request is merged. However, we're running into an issue where a developer might open two or three pull requests in small parts that merge into a feature branch, and merging those PRs cause the transition to trigger prematurely.  

I'm curious if there's a way to tweak any parameters on the "pull request merged" event and filter it based on a specific branch name or regex pattern? That way, we could restrict the transition to only trigger for pull requests that target our develop branch, and ignore PR merges that occur in branches with another name/pattern. 

Looking through the Workflow/Transition settings, I don't see a way to do that - is this possible?

Olga Buslovich February 10, 2020

@Daniel Eads  I have the same issue as @Mitch Ware   in my setup . Any suggestions , advise how to configure the trigger or automation rule that would transition the issues not for any merge but only for one that specified like DEV or QA branch.

TIA!

Olga

Like # people like this
Alexey Livintsev September 8, 2021

I found the solution for the specific branch: main in our case: 

Screenshot (283)_LI.jpg

3 votes
Ivana Rodriguez January 8, 2020

Hi all! I'm trying to accomplish something similar, but I can't seem to figure it out. Essentially, I want to transition JIRA issues into a 'QA' workflow status when changes are merged into a specific branch (ex. qa) in GitLab. Is this possible?

Olga Buslovich February 10, 2020

@Etienne Noel   We are experiencing the same needs. Please advise!

Thanks, Olga

Like # people like this
0 votes
Adrian SMYTH October 1, 2020
0 votes
Daniel Eads
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 11, 2019

Hey Grant,

Smart commits were my first thought when reading the title of your question. However, I think for your case you want Workflow Triggers instead. These are supported with Jira Cloud and Github (both Cloud and Github Enterprise) so you should be able to get this set up. The document goes into significant detail on what triggers you can utilize as well as how to set them up.

Let me know if you run into any trouble getting configured and I'd be happy to help!

Cheers,
Daniel

Etienne Noel September 24, 2019

This still doesn't work for next-gen projects though right?

Daniel Eads
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 24, 2019

@Etienne Noel that's correct - the status today is that advanced workflow editing (workflow triggers, for example) isn't available in next-gen projects. The current projection for this on the next-gen roadmap mentions 2020 as the "coming" estimate for the next-gen workflow editor.

Suggest an answer

Log in or Sign up to answer