Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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

Hello!

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

Jira Automation Rules 

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

Daniel Eads Atlassian Team Apr 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

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

Hi @Daniel Eads 

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

Thanks!

Daniel Eads Atlassian Team Sep 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 

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

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

Like # people like this

+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

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"

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

@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.)

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

@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.)

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

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.

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

@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 Ivana Rodriguez likes this

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

Screenshot (283)_LI.jpg

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?

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

Thanks, Olga

Like # people like this
0 votes
Daniel Eads Atlassian Team Mar 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

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

Daniel Eads Atlassian Team Sep 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
TAGS
Community showcase
Published in Jira

Admins, notify your Jira instance of system-wide changes with the new admin announcement banner

Hi All! We’re excited to share the launch of an announcement banner that lets Jira site administrators communicate directly to their users across Jira Cloud instance.   📢 Get y...

70 views 2 4
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you