Create Jira Issue on Build Failure through Jenkins

Now a days, its quite necessary and really very useful to integrate Jira with Jenkins

Jira can be used as Issue Tracking, Project management,etc for your project and brings Agility with its Scrum board and processes.

The most common use case is to update Jira ticket as and when there is an update on Jenkins build job.

How to achieve that ?

Lets discuss this today and see how can we update Jira issue whenever there is a failure on your respective Jenkins build job.

You can create a JIRA issue in the project with the given Jira project key.

  • If current build failed, checks if issue was already created. If yes, adds a comment, if not, creates a new JIRA issue.
  • If current build passed, checks if issue from p.1 is Closed or Done. If not, adds a comment.
  • And if the issue is not fixed and build has failed again- It will add the comment on existing jira issue.

To begin with the process you should first :-

Install Jira plugin in Jenkins

Check out the Jira Plugins in Jenkins wiki

And then download and install through Manage Jenkins —> Manage Plugins

Then Go to Configure system and fill your Jira site details

Once done – Open your Jenkins project

Click on Post build actions

Choose “Create Jira issue

And fill the details accordingly.

Since you have already configured your Jira project in Configure system, the details will be fetch and auto populated from your Jira instance to Jenkins Project.

Provide the Jira Project Key and Description the the test

Then choose Issue priority from the dropdown (It will fetch the Priority field from provide Jira project)

Select Issue Type (You need to provide the issue type which you want to be created in Jira for that particular project whenever there is any update through Jenkins build)

Then select the Action Id

Save it

Now, whenever the build gets failed, Jenkins will create an issue in Jira project.

Lets try some cases :

Case# 1 – Build is failed. Now Jenkins should create an issue inside the given Jira Project

Lets check our Jira, whether Jenkins has created the issue or not ?

Yes, it has created a Jira issue 🙂

Lets proceed and test another case

Case# 2 – Build has failed again and now Jenkins should add the comment on existing jira issue.

Lets check our Jira instance again, whether Jenkins has update the issue or not ?


Hurrayyy – Jenkins has updated the same issue as expected.

Folks, today we have seen how to create a Jira issue through Jenkins by following very simple steps.

Hope you enjoyed reading this article. Will be back with new Jenkins error soon.

Till then, stay tuned ……

11 thoughts on “Create Jira Issue on Build Failure through Jenkins”

      1. I am getting null pointer exception as Other fields like version, application type are mandatory fields in my app to create jira. but on job configuration i don’t know where to configure that.

        : JIRA REST createIssue error: RestClientException{statusCode=Optional.of(400), errorCollections=[ErrorCollection{status=400, errors={customfield_15607=ALM Project Name is required., customfield_15407=Detected in Cycle is required., customfield_11602=Application is required., customfield_11604=Severity is required., versions=Affects Version/s is required., customfield_15608=Detected in Env is required., fixVersions=Fix Version/s is required., customfield_15405=Test Phase is required., customfield_15601=Team Category is required.}, errorMessages=[]}]}

        ERROR: Build step failed with exception
        at hudson.plugins.jira.JiraSession.createIssue(
        at hudson.plugins.jira.JiraCreateIssueNotifier.createJiraIssue(
        at hudson.plugins.jira.JiraCreateIssueNotifier.currentBuildResultFailure(
        at hudson.plugins.jira.JiraCreateIssueNotifier.perform(
        at hudson.tasks.BuildStepMonitor$3.perform(
        at hudson.model.AbstractBuild$AbstractBuildExecution.perform(
        at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(
        at hudson.model.Build$BuildExecution.post2(
        at hudson.model.AbstractBuild$
        at hudson.model.Run.execute(
        at hudson.model.ResourceController.execute(
        Build step ‘JIRA: Create issue’ marked build as failure
        Finished: FAILURE

        1. Hi Lakshmi,
          Thanks for the details and sorry for delay in reply.
          As shown in the error message Jenkins is not able to fill the custom fields with your configuration.

          The easiest option is to use “Jenkins pipeline script to update Jira fields”, please refer :-

          Or you can also use JIRA REST APIs which are straight forward and easy to use. please refer :-

  1. Hi Ravi varma,
    I am using jenkins 2 version , i have installed jira plugin as you have shown , but i am facing issue during configuration like login failed (Basic auth with password is not allowed on this instance). Please help me out it would be great .

    1. Hi Rani,
      Please provide more details for the issue. Are you getting error (Basic auth with password is not allowed on this instance) or Your organisation doesn’t allow you to use username:password to login to Jira/Configure in Jenkins ?

      Are you using Jira cloud ? – then you would need to create the API Token

      If on-premises then :
      Are you able to login to Jira instance using the given credential?
      Are the permission been provided correctly ?
      Please provide the complete stacktrace from Jenkins log

Leave a Comment

Your email address will not be published. Required fields are marked *