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

你离开我真会死。 提交于 2019-12-24 12:22:26

问题


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.


回答1:


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"


来源:https://stackoverflow.com/questions/34451616/jira-how-to-make-a-webhook-fire-for-only-a-single-transition-of-a-workflow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!