Tools2023-06-19

How to Integrate Jenkins with Jira? A Step-by-Step Guide

Enhance workflow efficiency: Integrate Jenkins with Jira effortlessly. Set up triggers, install plugins, and track issues seamlessly with our guide.
Jenkins and Jira Integration

Jenkins and Jira are two popular tools used in software development. Jenkins is an automation tool that allows developers to automate their builds, tests, and deployments, while Jira is a project management tool used to track issues and manage workflows. Integrating Jenkins with Jira can help streamline the development process by allowing developers to track issues and monitor progress directly from their Jenkins environment.

The Jira plugin integrates with Jenkins for your Jira workflow, where you can monitor all your builds without leaving your Jira workspace. The plugin integrates with both cloud and server versions of Jenkins.

In this article, we will discuss the steps required to integrate Jenkins with Jira.

How to integrate Jenkins with Jira

Step 1: Install the Jira Plugin for Jenkins

The first step in integrating Jenkins with Jira is to install the Jira Plugin for Jenkins. To do this, navigate to the Jenkins dashboard and select Manage Jenkins -> Manage Plugins -> Available. Search for "Jira Plugin" and install it. 

  • You can also use the Jenkins CLI to run your installation by running the command below:
Jenkins CLI
  • Or the direct download option by going through the list of available releases. And upload it to your Jenkins instance.

Step 2: Configure the Jira Plugin in Jenkins

After installation is done for the Jira plugin, navigate to the Jenkins dashboard and select Manage Jenkins -> Configure System. Scroll down to the Jira section and enter the Jira server URL, username, and password.

Next, you move to create API tokens for service calls that will be used by the user to execute calls to Jira clouds.

Step 3: Create a Jira API Token

To allow Jenkins to communicate with Jira, you need to create a Jira API token. To do this, log in to your Jira account, click on your profile picture, and select "Account Settings." Next, click on the "Security" tab and select "Create and manage API tokens." Generate a new token and copy it to your clipboard.

Step 4: Configure the Jira Plugin in Jenkins with API Token

Navigate back to the Jenkins dashboard and select Manage Jenkins -> Configure System. Scroll down to the Jira section and enter the Jira server URL, username, and API token.

Step 5: Configure the Jira Trigger in Jenkins

Now that the Jira Plugin is configured in Jenkins, you can set up a Jira trigger to automatically start a Jenkins build when a Jira issue is updated. To do this, navigate to the Jenkins dashboard and select New Item. Enter a name for the job and select "Freestyle project."

Scroll down to the "Build Triggers" section and select "Jira Trigger." Enter the Jira project key and the JQL (Jira Query Language) filter that you want to use to trigger the build. You can also specify additional build parameters, such as the branch to build or the Maven goals to execute.

The Jira Trigger configuration allows users to set up rules to trigger Jenkins builds when certain Jira events occur. In addition to specifying the Jira project key and JQL filter, users can also define advanced options for the Jira Trigger configuration, such as:

Frequency of Jira polling

By default, Jenkins checks for updates from Jira every minute. However, users can adjust the polling frequency by specifying the number of minutes between each check. This can help reduce the number of unnecessary build triggers and optimize the integration's performance.

Custom JQL queries

Users can define custom JQL queries to filter Jira issues and trigger specific builds. For example, users can set up a Jira Trigger to start a build when a Jira issue with a particular label is updated.

Trigger builds based on specific Jira issue fields:

In addition to the Jira issue status, users can also specify other fields to trigger builds, such as priority, assignee, or fix versions. This can provide more granular control over when Jenkins builds are triggered.

Step 6: Test the Integration

To test the integration, update an issue in Jira that matches the JQL filter you specified in the Jira trigger. This should trigger the Jenkins build to start automatically.

Jenkins has several plugins that can be integrated with Jira to enhance the integration's capabilities. Some of these plugins include:

JiraTestResultReporter

This plugin enables Jenkins to report test results to Jira. With this plugin, users can configure Jenkins to automatically update the Jira issue with the test results and link the test results to the Jira issue.

Jira Cloud Plugin

This plugin enables Jira to display information from Jenkins builds, such as build status, build number, and build duration. With this plugin, users can view Jenkins build information directly within Jira and easily navigate between Jira issues and Jenkins builds.

Jira Pipeline Steps

This plugin provides a set of Jira-related pipeline steps that users can use to incorporate Jira into their Jenkins Pipeline workflows. For example, users can use the JiraIssueUpdate step to update a Jira issue's status or fields based on the Pipeline's execution.

In case of critical errors or incidents, setting up a PagerDuty alert within your Jenkins can provide immediate notifications for quick response.

Troubleshooting Tips

There’s always a chance to encounter errors or issues during this integration. Here are some troubleshooting tips to help you resolve common issues:

  1. Verify Jira credentials
    Ensure that the Jira server URL, username, and API token are entered correctly in the Jira Plugin configuration in Jenkins.
  2. Review Jenkins Logs
    Check the Jenkins logs for any error messages related to the Jira Plugin or Jira Trigger. These error messages can provide insights into the root cause of the issue.
  3. Review Jira Logs
    Check the Jira logs for any error messages related to the Jira webhook or REST API. These error messages can help identify any issues with Jira's communication

[ Read Related: Steps to Setup Jenkins Pipeline on AWS ]

Boost Productivity with Jenkins-Jira Integration

Integrating Jenkins with Jira can help streamline the software development process by allowing developers to track issues and monitor progress directly from their Jenkins environment. The steps required to integrate Jenkins with Jira are straightforward, and the benefits of doing so are significant. By following the steps outlined in this article, you can quickly and easily integrate Jenkins with Jira and start enjoying the benefits of streamlined software development.

However, simply using Jenkins or Jira, might not be enough to get the best out of your project space, an engineering analytics tool can equip you with the data-driven insights you need to place your team on top. Hatica offers metrics across 13 dashboards, powered by CI/CD tools, JiraGitHub, Azure, CircleCI, and GitLab. By collating tool activities at one place, Hatica helps teams streamline their workflow and improve productivity.

Subscribe to the Hatica blog today to read more about unblocking developers, and boosting productivity with engineering analytics.

Share this article:
Table of Contents
  • How to integrate Jenkins with Jira
  • Step 1: Install the Jira Plugin for Jenkins
  • Step 2: Configure the Jira Plugin in Jenkins
  • Step 3: Create a Jira API Token
  • Step 4: Configure the Jira Plugin in Jenkins with API Token
  • Step 5: Configure the Jira Trigger in Jenkins
  • Step 6: Test the Integration
  • Troubleshooting Tips
  • Boost Productivity with Jenkins-Jira Integration

Ready to dive in? Start your free trial today

Overview dashboard from Hatica