kick off Jenkins builds from Jira

Rick Benoit November 19, 2013

Hi,

I'm looking for a way to kick off remote Jenkins builds from Jira. The idea is for the build to be triggered by a Jira workflow status transition. Is this possible? How best to go about it?

After rooting around here a few days I've gotten the idea hat a groovy script running in the ScriptRunner plugin and set up as a transition post-function might do the job. Will this work? Is there a better way?

I'm thinking the script would send a RESTful POST to Jenkins to kick off the build. It would have to get some data out of the issue (the one whose transition called it) first though, which I'm guessing would involve the Jira (java) API?

Just looking for some high-level guidance here, total Jira newbie.

thanks!

2 answers

1 accepted

1 vote
Answer accepted
Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 26, 2019

I know the thread is a bit outdated but maybe it can be useful to other people:

 

There is also a video on youtube showing how this works:

 

I hope this helps.

0 votes
Timothy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 20, 2013

I believe that Jenkins has a REST API. If you can figure that part out, you can use JIRA webhooks (https://developer.atlassian.com/display/JIRADEV/JIRA+Webhooks+Overview) to trigger or call those REST API.

Rick Benoit November 20, 2013

Yes, Webhooks would seem to be the answer. Unfortunately, HTTP Basic Auth is broken in Webhooks (has been since inception) so you can only do anonymous POSTs that way, which won't cut it in our environment. What I'm really looking for is a workaround to the broken Webhooks problem, ScriptRunner looks like a possibility but I'm not sure its the best one.

https://jira.atlassian.com/browse/JRA-31953

mc March 9, 2015

Came across this looking for a solution to the same problem. What I did as a quick workaround was setup a flask application that accepts the Jira Webhook post, grabs the details of the ticket needed to run the Jenkins build, and sends a post to the Jenkins API to run the build. It works really well - I even have Jenkins sending back the build ID and periodic status updates as the build goes through the pipe line (readiness check, build, db updates, deployment, build complete).

Mani September 26, 2017

can u please suggest me the configuration , please

Suggest an answer

Log in or Sign up to answer