Can I configure jira workflow pull request merge trigger to only respond on merge on a particular branch?

Bobby Heath October 30, 2015

My particular git branching strategy includes dedicated branches for environments.  I.E. I have a prod branch for deployment to the production environment and a staging branch to deploy to the staging environment.

 I also have Jenkins  jobs configured to poll these branches and deploy to their respective environments.  I recently attempted to set up a workflow in JIRA to trigger a transition upon pull request merge to advance a referrenced JIRA issue to a particular status.  In this case, I am trying to have the trigger advance the issue to the "Deployed to Staging" on the pull request merge to the Staging branch only.  This doesn't seem to be happening.  Is there something I am missing here?  Is there some way to configure the trigger to only look at the staging branch?

2 answers

0 votes
Antonius Golly November 28, 2019

Though the whole internet is saying it isn't possible, it is in fact possible without smart commits but with some more engeneering and a little mind-shift:

  • Reflect Bitbucket branches in the Jira ticket status (that is the crucial bit)
  • Dfine the triggers in status to status transition (in contrast to a "from all"-transition)

Example:
Say you have this workflow: (status) [Trigger]

  • PM creates ticket ("open") 
  • Dev creates branch ("in progress") [T1]
  • Dev works on issue
  • Dev creates PR to branch develop ("in review") [T2]
  • PR is merged ("staging") [T3]
  • Lead creates PR to branch master
  • Lead merges PR ("done") [T4]

Now, let's look at the triggers:

  • T1: Create Branch trigger
  • T2: Create Pull request
  • T3: Pull request merged
  • T4: Pull request merged

When you attach all these transitions to the "from all" transition the first merged PR will move the ticket to done, and the second PR created will move the ticket back to "in review" no matter what. That's not what you want. 

If you define individual transitions and define the trigger there, it works like a filter. 

0 votes
Jeff Musser March 31, 2016

The triggers they have on transitions are too limited.  You will have to enable Smart Commits and leverage that.  It will be more flexible, but not as automatic.  In your commit comment you will have to enter commands such as: <Card ID> #deployed-to-staging <comment> (for your example above)

Suggest an answer

Log in or Sign up to answer