labheshr
labheshr

Reputation: 3056

Git hook: once a branch is merged into master - update JIRA status

I am new to writing git hooks. Here's what I'd like to do:

Once a branch XYZ is merged into master (on remote); write a hook that changes the status of a JIRA ticket associated with branch XYZ from "pending approval" to "prod ready".

My research into this so far:

  1. I've figured JIRA Rest API can allow me to do this (using POST transaction + OAuth API).
  2. Git hooks can be written in many languages (and I figured python would be the easiest for me as I am well versed in it) .
  3. I should be implementing either post-merge or post-receive git hook to do this. The hook would essentially get the Branch name (my branch name is enforced to be the same as Jira name) ; and then do a POST using JIRA API to change the status as mentioned above.
  4. There is such a thing as "web hooks" that are also an option for folks using github. My repo at the moment is github deployed into the organization..but we might be moving toward bitbucket; in which case I am concerned that webhooks will no longer be useful...

My questions:

  1. Is it possible to accomplish this task?
  2. If so, what githook should I be using? post-merge or post-receive?

  3. Should I be using web hooks or githook?

  4. Can anyone point me to an example to get me started?

Thanks

Upvotes: 2

Views: 1609

Answers (1)

labheshr
labheshr

Reputation: 3056

Found the answer ...Here's how to do it - for those interested:

https://confluence.atlassian.com/adminjiracloud/configuring-workflow-triggers-776636696.html

  • Esssentially, Jira has a "workflow" section; in which you can create a "trigger".
  • The trigger can be activated to perform a "transition"...which is to say the status of the JIRA can be changed using this trigger.
  • Its all UI driven; so you don't have to script a githook or a
    webhook

Upvotes: 3

Related Questions