Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-30682

Ticket creation fails when no components in JIRA project exist / JIRA rejects empty component list

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Trivial
    • Resolution: Fixed
    • jira-plugin

    Description

      Having an issue getting the plugin to create a JIRA ticket. See the configuration screenshots attached for how I've got it setup.

      The error I'm getting is during a failed build is:

      Recording test results
      ERROR: Build step failed with exception
      java.lang.NullPointerException
              at hudson.plugins.jira.JiraSession.createIssue(JiraSession.java:310)
              at hudson.plugins.jira.JiraCreateIssueNotifier.createJiraIssue(JiraCreateIssueNotifier.java:153)
              at hudson.plugins.jira.JiraCreateIssueNotifier.currentBuildResultFailure(JiraCreateIssueNotifier.java:343)
              at hudson.plugins.jira.JiraCreateIssueNotifier.perform(JiraCreateIssueNotifier.java:115)
              at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
              at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
              at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:726)
              at hudson.model.Build$BuildExecution.post2(Build.java:185)
              at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:671)
              at hudson.model.Run.execute(Run.java:1766)
              at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
              at hudson.model.ResourceController.execute(ResourceController.java:98)
              at hudson.model.Executor.run(Executor.java:408)
      Build step 'Create Jira Issue' marked build as failure
      

      If I call our JIRA rest API from the server I can create an issue just fine.

      curl -D- -u username:password -X POST --data @data.txt -H "Content-Type: application/json" https://destinationnsw.atlassian.net/rest/api/2/issue/
      

      data.txt contains:

      {
          "fields": {
             "project":
             {
                "key": "BUGS"
             },
             "summary": "REST ye merry gentlemen.",
             "description": "Creating of an issue using project keys",
             "issuetype": {
                "name": "Bug"
             }
         }
      }
      

      I get "HTTP/1.1 201 Created" and the ticket is available.

      Attachments

        1. build_changelog.png
          build_changelog.png
          35 kB
        2. build_error_message_v141.png
          build_error_message_v141.png
          46 kB
        3. build_error_message_v2.png
          build_error_message_v2.png
          66 kB
        4. create_jira_issue.png
          create_jira_issue.png
          27 kB
        5. global config.png
          global config.png
          52 kB
        6. jira_configuration.png
          jira_configuration.png
          53 kB
        7. project config.png
          project config.png
          91 kB
        8. project config - version 2.png
          project config - version 2.png
          21 kB

        Activity

          I was able to replicate NPE like yours when the assignee field had a non-existent entry. Other than that I got a different error.

          • does the JIRA connection validate in configuration and JIRA connection is working fine for other things?
          • can you try doing curl with exact the same data? (e.g. with category included)
          warden Radek Antoniuk added a comment - I was able to replicate NPE like yours when the assignee field had a non-existent entry. Other than that I got a different error. does the JIRA connection validate in configuration and JIRA connection is working fine for other things? can you try doing curl with exact the same data? (e.g. with category included)
          thomwilhelm Thom Wilhelm added a comment - - edited

          Hi warden the "Validate Settings" button I've found to be almost useless, if I change the URL to something completely random https://fjjfs.sdggdsdgssdg.xyz, or fill out the username/password to deliberately invalid credentials I still receive "Success". It's almost like this check doesn't actually connect to the server, it just validates the fields are filled out.

          I'll experiment with entering an assignee, although I had already tried this I believe. I'll get back to you after I've conducted some more CURL tests. What do you mean "with category included", is this similar to project key or component?

          thomwilhelm Thom Wilhelm added a comment - - edited Hi warden the "Validate Settings" button I've found to be almost useless, if I change the URL to something completely random https://fjjfs.sdggdsdgssdg.xyz , or fill out the username/password to deliberately invalid credentials I still receive "Success". It's almost like this check doesn't actually connect to the server, it just validates the fields are filled out. I'll experiment with entering an assignee, although I had already tried this I believe. I'll get back to you after I've conducted some more CURL tests. What do you mean "with category included", is this similar to project key or component?

          Yeap, sorry, I meant component.
          You're also right about the Validate Settings button, AFAIR I fixed this in master already but it's not there yet in 2.0.2.

          warden Radek Antoniuk added a comment - Yeap, sorry, I meant component. You're also right about the Validate Settings button, AFAIR I fixed this in master already but it's not there yet in 2.0.2.
          thomwilhelm Thom Wilhelm added a comment -

          Hi warden I'm getting the same NullPointerException even with the assignee field filled out (see the update config screenshot). I removed the "Component Name" field as I'm assuming this is optional.

          ERROR: Build step failed with exception
          java.lang.NullPointerException
          at hudson.plugins.jira.JiraSession.createIssue(JiraSession.java:305)
          at hudson.plugins.jira.JiraCreateIssueNotifier.createJiraIssue(JiraCreateIssueNotifier.java:153)
          at hudson.plugins.jira.JiraCreateIssueNotifier.currentBuildResultFailure(JiraCreateIssueNotifier.java:343)
          at hudson.plugins.jira.JiraCreateIssueNotifier.perform(JiraCreateIssueNotifier.java:115)
          at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
          at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
          at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:726)
          at hudson.model.Build$BuildExecution.post2(Build.java:185)
          at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:671)
          at hudson.model.Run.execute(Run.java:1766)
          at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
          at hudson.model.ResourceController.execute(ResourceController.java:98)
          at hudson.model.Executor.run(Executor.java:408)
          Build step 'Create Jira Issue' marked build as failure

          Have you got any insight into why this might be failing? I can try to replicate with the REST API but am not familiar with how to exactly replicate the call you are making from the plugin.

          thomwilhelm Thom Wilhelm added a comment - Hi warden I'm getting the same NullPointerException even with the assignee field filled out (see the update config screenshot). I removed the "Component Name" field as I'm assuming this is optional. ERROR: Build step failed with exception java.lang.NullPointerException at hudson.plugins.jira.JiraSession.createIssue(JiraSession.java:305) at hudson.plugins.jira.JiraCreateIssueNotifier.createJiraIssue(JiraCreateIssueNotifier.java:153) at hudson.plugins.jira.JiraCreateIssueNotifier.currentBuildResultFailure(JiraCreateIssueNotifier.java:343) at hudson.plugins.jira.JiraCreateIssueNotifier.perform(JiraCreateIssueNotifier.java:115) at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45) at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779) at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:726) at hudson.model.Build$BuildExecution.post2(Build.java:185) at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:671) at hudson.model.Run.execute(Run.java:1766) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:98) at hudson.model.Executor.run(Executor.java:408) Build step 'Create Jira Issue' marked build as failure Have you got any insight into why this might be failing? I can try to replicate with the REST API but am not familiar with how to exactly replicate the call you are making from the plugin.

          Coming back to this, is the plugin working with JIRA at all for you?
          For instance, do you see JIRA issues annotated in the build Changelog and when you hover over them, you see the JIRA issue summaries?

          warden Radek Antoniuk added a comment - Coming back to this, is the plugin working with JIRA at all for you? For instance, do you see JIRA issues annotated in the build Changelog and when you hover over them, you see the JIRA issue summaries?

          Also, you may try to build it from master branch and try out JIRA connection validation.

          warden Radek Antoniuk added a comment - Also, you may try to build it from master branch and try out JIRA connection validation.
          thomwilhelm Thom Wilhelm added a comment -

          Hey warden yep some parts of the plugin are working as expected.

          We've got another Jenkins job setup with the "Update relevant JIRA issues" option and this works correctly. But just can't get the 'Create Jira Issue' to work.

          thomwilhelm Thom Wilhelm added a comment - Hey warden yep some parts of the plugin are working as expected. We've got another Jenkins job setup with the "Update relevant JIRA issues" option and this works correctly. But just can't get the 'Create Jira Issue' to work.

          I'm having a similar error message:

          ERROR: Build step failed with exception
          java.lang.NullPointerException
          	at hudson.plugins.jira.JiraCreateIssueNotifier.currentBuildResultSuccess(JiraCreateIssueNotifier.java:373)
          	at hudson.plugins.jira.JiraCreateIssueNotifier.perform(JiraCreateIssueNotifier.java:119)
          	at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
          	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
          	at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:726)
          	at hudson.model.Build$BuildExecution.post2(Build.java:185)
          	at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:671)
          	at hudson.model.Run.execute(Run.java:1766)
          	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
          	at hudson.model.ResourceController.execute(ResourceController.java:98)
          	at hudson.model.Executor.run(Executor.java:381)
          

          I'm using jira-plugin 2.0.2, Jira 6.1.3 and Jenkins 1.619. I previously tried with jira-plugin 1.41 and had a similar error message.

          Except for creating an issue (my main use case!), other parts of the jira-plugin are working as expected (e.g. links to JIRA tickets in build changelogs, JIRA settings validation, etc.).

          cirulls Sandro Cirulli added a comment - I'm having a similar error message: ERROR: Build step failed with exception java.lang.NullPointerException at hudson.plugins.jira.JiraCreateIssueNotifier.currentBuildResultSuccess(JiraCreateIssueNotifier.java:373) at hudson.plugins.jira.JiraCreateIssueNotifier.perform(JiraCreateIssueNotifier.java:119) at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45) at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779) at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:726) at hudson.model.Build$BuildExecution.post2(Build.java:185) at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:671) at hudson.model.Run.execute(Run.java:1766) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:98) at hudson.model.Executor.run(Executor.java:381) I'm using jira-plugin 2.0.2, Jira 6.1.3 and Jenkins 1.619. I previously tried with jira-plugin 1.41 and had a similar error message. Except for creating an issue (my main use case!), other parts of the jira-plugin are working as expected (e.g. links to JIRA tickets in build changelogs, JIRA settings validation, etc.).

          So, an older JIRA and older plugin show the same problem. Sandro, can you add a screenshot of your JIRA config and full build plan config? I will try to replicate that tomorrow with 2.0.2.

          warden Radek Antoniuk added a comment - So, an older JIRA and older plugin show the same problem. Sandro, can you add a screenshot of your JIRA config and full build plan config? I will try to replicate that tomorrow with 2.0.2.
          cirulls Sandro Cirulli added a comment - - edited

          I attach the following screenshots:

          • JIRA configuration. This shows a success when I validate the settings (I confirm this works properly, if I try a non-existing URL or user I get an error).
          • Build changelog. This works correctly, I am able to see the link to a JIRA ticket.
          • Build job configuration with my JIRA project key and assignee.
          • Build error message with jira plugin version 2.0.2. I let a test fails on purpose in order to create a JIRA issue but this fails with the NullPointerException error message.
          • Build error message with jira plugin version 1.41. Same type of error message.

          My account does not have admin rights on JIRA but I am allowed to create a ticket on my JIRA instance.

          cirulls Sandro Cirulli added a comment - - edited I attach the following screenshots: JIRA configuration. This shows a success when I validate the settings (I confirm this works properly, if I try a non-existing URL or user I get an error). Build changelog. This works correctly, I am able to see the link to a JIRA ticket. Build job configuration with my JIRA project key and assignee. Build error message with jira plugin version 2.0.2. I let a test fails on purpose in order to create a JIRA issue but this fails with the NullPointerException error message. Build error message with jira plugin version 1.41. Same type of error message. My account does not have admin rights on JIRA but I am allowed to create a ticket on my JIRA instance.

          Sandro, your stacktrace looks different. Looks like you have an NPL on the line:

                      String comment = String.format("- Job is still failing.\n- Failed run : [%s|%s]\n** [console log|%s]",
                              buildNumber, buildURL, buildURL.concat("console"));
          

          while Thom has an NPE when actually trying to create the issue in JIRA in JiraSession class.
          That's interesting, looks like in your case buildNumber or buildURL is null.

          warden Radek Antoniuk added a comment - Sandro, your stacktrace looks different. Looks like you have an NPL on the line: String comment = String .format( "- Job is still failing.\n- Failed run : [%s|%s]\n** [console log|%s]" , buildNumber, buildURL, buildURL.concat( "console" )); while Thom has an NPE when actually trying to create the issue in JIRA in JiraSession class. That's interesting, looks like in your case buildNumber or buildURL is null.

          Is there anything I can try at my end? Or anything to help debugging it?

          cirulls Sandro Cirulli added a comment - Is there anything I can try at my end? Or anything to help debugging it?
          warden Radek Antoniuk added a comment - - edited

          thomwilhelm, what do you see in the Jenkins log? You should some error like this:

          WARNING: jira rest client create issue error. cause: RestClientException{statusCode=Optional.of(400), errorCollections=[ErrorCollection{status=400, errors={issuetype=valid issue type is required}, errorMessages=[]}]}
          
          warden Radek Antoniuk added a comment - - edited thomwilhelm , what do you see in the Jenkins log? You should some error like this: WARNING: jira rest client create issue error. cause: RestClientException{statusCode=Optional.of(400), errorCollections=[ErrorCollection{status=400, errors={issuetype=valid issue type is required}, errorMessages=[]}]}

          cirulls take a look at JENKINS-16225 as a wild guess. Try adding a task that runs "env" and see if variables contain BUILD_NUMBER or BUILD_URL. If they do not, you have a problem there.

          warden Radek Antoniuk added a comment - cirulls take a look at JENKINS-16225 as a wild guess. Try adding a task that runs "env" and see if variables contain BUILD_NUMBER or BUILD_URL. If they do not, you have a problem there.
          thomwilhelm Thom Wilhelm added a comment -

          Hi warden in my file /var/log/jenkins/jenkins.log I'm getting the following line only when a build fails:

          INFO: Sydney.com-IN #7 main build action completed: FAILURE

          I can see some older ones from before that mention component was not found eg.

          WARNING: jira rest client create issue error. cause: RestClientException{statusCode=Optional.of(400), errorCollections=[ErrorCollection{status=400, errors=

          {components=Field 'components' cannot be set. It is not on the appropriate screen, or unknown.}

          , errorMessages=[]}]}

          But I'm not entering a component value anymore. Same response as before with the NPE:

          java.lang.NullPointerException
          at hudson.plugins.jira.JiraSession.createIssue(JiraSession.java:305)
          ... etc ...

          thomwilhelm Thom Wilhelm added a comment - Hi warden in my file /var/log/jenkins/jenkins.log I'm getting the following line only when a build fails: INFO: Sydney.com-IN #7 main build action completed: FAILURE I can see some older ones from before that mention component was not found eg. WARNING: jira rest client create issue error. cause: RestClientException{statusCode=Optional.of(400), errorCollections=[ErrorCollection{status=400, errors= {components=Field 'components' cannot be set. It is not on the appropriate screen, or unknown.} , errorMessages=[]}]} But I'm not entering a component value anymore. Same response as before with the NPE: java.lang.NullPointerException at hudson.plugins.jira.JiraSession.createIssue(JiraSession.java:305) ... etc ...

          Code changed in jenkins
          User: Radosław Antoniuk
          Path:
          src/main/java/hudson/plugins/jira/JiraCreateIssueNotifier.java
          src/main/java/hudson/plugins/jira/JiraRestService.java
          src/main/java/hudson/plugins/jira/JiraSession.java
          http://jenkins-ci.org/commit/jira-plugin/43f5439fa5e5ea2dbc4b74773945b242db551913
          Log:
          JENKINS-30682 - Fix NPE on empty Component list in JIRA project. #nomerge - this was already changed in master.

          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Radosław Antoniuk Path: src/main/java/hudson/plugins/jira/JiraCreateIssueNotifier.java src/main/java/hudson/plugins/jira/JiraRestService.java src/main/java/hudson/plugins/jira/JiraSession.java http://jenkins-ci.org/commit/jira-plugin/43f5439fa5e5ea2dbc4b74773945b242db551913 Log: JENKINS-30682 - Fix NPE on empty Component list in JIRA project. #nomerge - this was already changed in master.

          Code changed in jenkins
          User: Radosław Antoniuk
          Path:
          src/main/java/hudson/plugins/jira/JiraCreateIssueNotifier.java
          src/main/java/hudson/plugins/jira/JiraRestService.java
          src/main/java/hudson/plugins/jira/JiraSession.java
          http://jenkins-ci.org/commit/jira-plugin/c3c8ca670a38913a2a9398a85662a0bbb8301638
          Log:
          Merge pull request #65 from jenkinsci/jira-2.0.3

          JENKINS-30682 - Fix NPE on empty Component list in JIRA project.

          Compare: https://github.com/jenkinsci/jira-plugin/compare/1a177053e8a8...c3c8ca670a38

          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Radosław Antoniuk Path: src/main/java/hudson/plugins/jira/JiraCreateIssueNotifier.java src/main/java/hudson/plugins/jira/JiraRestService.java src/main/java/hudson/plugins/jira/JiraSession.java http://jenkins-ci.org/commit/jira-plugin/c3c8ca670a38913a2a9398a85662a0bbb8301638 Log: Merge pull request #65 from jenkinsci/jira-2.0.3 JENKINS-30682 - Fix NPE on empty Component list in JIRA project. Compare: https://github.com/jenkinsci/jira-plugin/compare/1a177053e8a8...c3c8ca670a38

          Code changed in jenkins
          User: Radosław Antoniuk
          Path:
          src/main/java/hudson/plugins/jira/JiraCreateIssueNotifier.java
          src/main/java/hudson/plugins/jira/JiraRestService.java
          src/main/java/hudson/plugins/jira/JiraSession.java
          http://jenkins-ci.org/commit/jira-plugin/23ee171d68e52c2f6634f11405c9620411a5c543
          Log:
          JENKINS-30682 - Fix NPE on empty Component list in JIRA project. #nomerge - this was already changed in master.

          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Radosław Antoniuk Path: src/main/java/hudson/plugins/jira/JiraCreateIssueNotifier.java src/main/java/hudson/plugins/jira/JiraRestService.java src/main/java/hudson/plugins/jira/JiraSession.java http://jenkins-ci.org/commit/jira-plugin/23ee171d68e52c2f6634f11405c9620411a5c543 Log: JENKINS-30682 - Fix NPE on empty Component list in JIRA project. #nomerge - this was already changed in master.

          Thom, I just released v.2.0.3, give it a try and let me know how it goes.

          warden Radek Antoniuk added a comment - Thom, I just released v.2.0.3, give it a try and let me know how it goes.
          thomwilhelm Thom Wilhelm added a comment -

          Hey warden thanks so much that's fixed the issue for us. Legend.

          Big up yourself.

          thomwilhelm Thom Wilhelm added a comment - Hey warden thanks so much that's fixed the issue for us. Legend. Big up yourself.

          People

            warden Radek Antoniuk
            thomwilhelm Thom Wilhelm
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: