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.
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.
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.
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).
Atlassian Summit is an excellent opportunity for in-person support, training, and networking.Learn more
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG