简体   繁体   中英

JIRA: How to make a webhook fire for only a single transition, of a workflow?

Scenario is :

Git -> JIRA -> Jenkins

A commit in Git, must change an issue status in JIRA, which in turn, should trigger a build for a job in Jenkins.

Method Tried :

  1. I created a WebHook in JIRA. This webhook contains the URL for a Jenkins job.
  2. Attached this WebHook to a Work Flow in JIRA, as a post function .
  3. The workflow is a simple one. It says: [InReview]-->[InProgress]-(Aprrove)->[Done]
  4. The webhook is attached to the transition from [InProgress] to [Done]
  5. IssueKey and Issue-Updated has been mentioned in the WebHook. IssueKey will make that WebHook work only for a specific issue. Issue-Updated is an event that will fire WebHook, when that specific issue is updated.

Now, when I do a Git commit, status of Jira issue changes from InReview to InProgress and an Approve button appears. When I check in Jenkins, a build is triggered because of this issue change. Again I'll go back to JIRA, hit the Approve button, Issue status changes from InProgress to Done and this too triggers a build in Jenkins.

My requirement is that the Jenkins build should happen only on InProgress to Done status change. I am not able to point out the reason that why the InReview to InProgress transition triggers a Jenkins build.

Any pointers on this would be of great help. Thanks in advance.

After a lot of hit and trials, finally JQL did the trick for me. I edited the WebHook as follows:

In the Events (Issue related events) section, which says (Events for issues and worklogs. You can specify a JQL query to send only events triggered by matching issues.), I entered:

issuekey = "Issue-ID" AND status = "In Review"

"Issue-ID" mentioned in above line of code is for reference. In actual, its a 3 lettered word followed by the issue number, like : ABC-1

This will trigger the action(webhook) for a transition from a particular status. The moral of the story is: All transitions which source from "this value" in JQL query status="this value" , will fire the webhook.

Edit 1: To make the webhook more transition specific, so that it fires for one and only one transition, we can use the JQL as:

status CHANGED FROM "In Progress" TO "Open"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM