Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to trigger a Jenkins job from a status change in Jira

I have been looking for a while now for a way to trigger a Jenkins job from the status or a ticket/story in Jira changing status. To give a more detailed example when my team moves a ticket to the 'ready for test' column we would like to be able to trigger a sanity test pack in Jenkins, the ideal situation would then be that we are able to post the results (generated as a html) as a comment on the ticket within Jira. Failing that we would like to be able to publish the results as simply pass/fail.

I have recently been looking at the Jenkins Jira plugin but this does not seem to have the functionality to work both ways, in other words it can post results after a job has run but you cannot trigger the job from a change of status in Jira. Is there any such plugin available or is it something that we will need to create ourselves?

Cheers in advance

like image 833
user2131710 Avatar asked May 06 '15 15:05

user2131710


2 Answers

So, basicly there are webhooks in jira (https://developer.atlassian.com/jiradev/jira-architecture/webhooks). With it you can configure it to trigger specific url on issue status change. The specific url should be jenkins API, for example for triggering a build you should call an external url like (if you are building with parameters): http://server/job/myjob/buildWithParameters?token=TOKEN&PARAMETER=Value

Some more info https://wiki.jenkins-ci.org/display/JENKINS/Remote+access+API

like image 77
Stan E Avatar answered Oct 03 '22 00:10

Stan E


I have written a Jenkins plugin that supports JIRA status change trigger: jira-trigger-plugin.

This plugin also injects an environment variable of JIRA_ISSUE_KEY, so you can utilise this information to publish your result back to JIRA e.g. using REST API.

like image 25
ceilfors Avatar answered Oct 03 '22 01:10

ceilfors