Trigger the Jenkins build from Jira Automation

Still need help?

The Atlassian Community is here for you.

Ask the community

robotsnoindex

 

Platform Notice: Cloud, Server, and Data Center - This article applies equally to all 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.

Environment

Jira Cloud, Server/DataCenter.

(warning) Note that the screenshot showing the automation rule configuration was taken from a Jira Cloud environment, but the same configuration is also available in Jira Server/Data Center.

Solution

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

Prerequisite

  • The Jenkins host should be outside proxy and need to be 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 accepting 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 the 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.

     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".
  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. All these setups in place, your build should get triggered perfectly.

Last modified on May 30, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.