Trigger the Jenkins build from Jira Automation

Platform Notice: Cloud and Data Center - This article applies equally to both cloud and data center platforms.

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

This page will help to configure the Automation rule in Jira to trigger the Jenkins build. Also, you would be able to use the Jenkins credential as a parameter.

Solution

The solution is to use the Jira Automation Send Web method action.

Prerequisite

  • The Jenkins host should be outside a proxy and reachable to Jira. Basically, the Jenkins host should be on the Internet.

  • You need to ensure that Jenkins is able to trigger the build using the Jenkins API.

  • Also, the Jenkins URL should be open to accept the incoming connection at 80 & 443 ports.

  • Change the Jenkins <username>:<password> or the <username>:<password> to hashcode base64. You may generate the base64 from here.

  • Now, try to initiate the Jenkins build from your local machine (outside the company network) using the Jenkins endpoint.

  • The build should be triggered from outside Jira to confirm that Jenkins is able to accept all the parameters. The cURL command mentioned on this page might be useful to try your Jenkins command.

1 curl --request POST 'http://<Jenkins URL>/job/Test/build' \ --header 'Authorization: basic <base64 hashcode>'

Please proceed to the next setup only if the prerequisite is completed.

How to trigger Jenkins Build from Jira Automation?

  1. Create a new Automation Rule trigger as per the use case.

    e.g when the sprint is close trigger this rule, when the issue is created, etc..

  2. In the action choose the action as "Send Web Method".

    Choose "send web method" action
  3. Provide the public available Jenkins URL on this page.

  4. Provide the authentication in the header field If the Jenkins host needs the authentication. Refer to this community post to understand how we could pass the authentication for the URL.

  5. Click on the "Validate" option on the page to test the connection.

  6. With all these setups in place, your build should get triggered perfectly.

Updated on June 13, 2024

Still need help?

The Atlassian Community is here for you.