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

Builds failing because Run defining the context within which to find P4 credential is null

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Component/s: core, p4-plugin
    • Labels:
      None
    • Environment:
      Jenkins Server: Windows Server 2012 R2 (x86)
      Slave Node: Linux CentOS 7 (amd64) (virtual machine)
      Jenkins 2.219
      P4 Plugin 1.10.9
    • Similar Issues:

      Description

      After an upgrade from Jenkins version 2.214 to 2.219, 2 of my Jenkins builds always fail within a few seconds and show the following stack trace:

      FATAL: null
      java.lang.NullPointerException
      at java.util.Objects.requireNonNull(Unknown Source)
      at com.cloudbees.plugins.credentials.CredentialsProvider.findCredentialById(CredentialsProvider.java:873)
      at org.jenkinsci.plugins.p4.client.ConnectionHelper.findCredential(ConnectionHelper.java:917)
      at org.jenkinsci.plugins.p4.tagging.TagAction.getTicket(TagAction.java:218)
      at org.jenkinsci.plugins.p4.build.P4EnvironmentContributor.buildEnvironment(P4EnvironmentContributor.java:89)
      at org.jenkinsci.plugins.p4.build.P4EnvironmentContributor.buildEnvironment(P4EnvironmentContributor.java:32)
      at org.jenkinsci.plugins.p4.PerforceScm.buildEnvironment(PerforceScm.java:727)
      at hudson.scm.SCM.buildEnvVars(SCM.java:554)
      at org.jenkinsci.plugins.p4.PerforceScm.buildEnvVars(PerforceScm.java:719)
      at hudson.model.AbstractBuild.getEnvironment(AbstractBuild.java:871)
      at org.jenkinsci.plugins.p4.tasks.AbstractTask.setEnvironment(AbstractTask.java:92)
      at org.jenkinsci.plugins.p4.PerforceScm.checkout(PerforceScm.java:514)
      at hudson.scm.SCM.checkout(SCM.java:505)
      at hudson.model.AbstractProject.checkout(AbstractProject.java:1206)
      at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:574)
      at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
      at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:499)
      at hudson.model.Run.execute(Run.java:1853)
      at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      at hudson.model.ResourceController.execute(ResourceController.java:97)
      at hudson.model.Executor.run(Executor.java:428)
      Recording test results
      ERROR: Build step failed with exception
      java.lang.NullPointerException
      at java.util.Objects.requireNonNull(Unknown Source)
      at com.cloudbees.plugins.credentials.CredentialsProvider.findCredentialById(CredentialsProvider.java:873)
      at org.jenkinsci.plugins.p4.client.ConnectionHelper.findCredential(ConnectionHelper.java:917)
      at org.jenkinsci.plugins.p4.tagging.TagAction.getTicket(TagAction.java:218)
      at org.jenkinsci.plugins.p4.build.P4EnvironmentContributor.buildEnvironment(P4EnvironmentContributor.java:89)
      at org.jenkinsci.plugins.p4.build.P4EnvironmentContributor.buildEnvironment(P4EnvironmentContributor.java:32)
      at org.jenkinsci.plugins.p4.PerforceScm.buildEnvironment(PerforceScm.java:727)
      at hudson.scm.SCM.buildEnvVars(SCM.java:554)
      at org.jenkinsci.plugins.p4.PerforceScm.buildEnvVars(PerforceScm.java:719)
      at hudson.model.AbstractBuild.getEnvironment(AbstractBuild.java:871)
      at hudson.tasks.junit.JUnitResultArchiver.parseAndAttach(JUnitResultArchiver.java:165)
      at hudson.tasks.junit.JUnitResultArchiver.perform(JUnitResultArchiver.java:154)
      at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:78)
      at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
      at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:741)
      at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)
      at hudson.model.Build$BuildExecution.post2(Build.java:186)
      at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635)
      at hudson.model.Run.execute(Run.java:1878)
      at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      at hudson.model.ResourceController.execute(ResourceController.java:97)
      at hudson.model.Executor.run(Executor.java:428)
      Build step 'Publish JUnit test result report' marked build as failure
      ERROR: Build step failed with exception
      java.lang.NullPointerException
      at java.util.Objects.requireNonNull(Unknown Source)
      at com.cloudbees.plugins.credentials.CredentialsProvider.findCredentialById(CredentialsProvider.java:873)
      at org.jenkinsci.plugins.p4.client.ConnectionHelper.findCredential(ConnectionHelper.java:917)
      at org.jenkinsci.plugins.p4.tagging.TagAction.getTicket(TagAction.java:218)
      at org.jenkinsci.plugins.p4.build.P4EnvironmentContributor.java:89)
      at org.jenkinsci.plugins.p4.build.P4EnvironmentContributor.buildEnvironment(P4EnvironmentContributor.java:32)
      at org.jenkinsci.plugins.p4.PerforceScm.buildEnvironment(PerforceScm.java:727)
      at hudson.scm.SCM.buildEnvVars(SCM.java:554)
      at org.jenkinsci.plugins.p4.PerforceScm.buildEnvVars(PerforceScm.java:719)
      at hudson.model.AbstractBuild.getEnvironment(AbstractBuild.java:871)
      at hudson.tasks.Mailer.perform(Mailer.java:147)
      at hudson.tasks.Mailer.perform(Mailer.java:138)
      at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
      at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:741)
      at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)
      at hudson.model.Build$BuildExecution.post2(Build.java:186)
      at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635)
      at hudson.model.Run.execute(Run.java:1878)
      at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      at hudson.model.ResourceController.execute(ResourceController.java:97)
      at hudson.model.Executor.run(Executor.java:428)
      Build step 'E-mail Notification' marked build as failure
      Finished: FAILURE

      I have never seen this failure before and nothing has been changed on the machine on which Jenkins runs these 2 builds, nor has anything been changed on Jenkins except for the version upgrade. Furthermore, the 2 other builds that run on that machine still work normally.

      In GitHub, I had looked at the code the stack trace refers to. I looked at CredentialsProvider at https://github.com/jenkinsci/credentials-plugin/blob/master/src/main/java/com/cloudbees/plugins/credentials/CredentialsProvider.java , as this is what the 2nd line of the stack trace refers to. The problem is that the "Run defining the context within which to find the credential" is null. The 4th line of the stack trace is P4BaseCredentials auth = ConnectionHelper.findCredential(credential, getRun()); which can be found at https://github.com/jenkinsci/p4-plugin/blob/master/src/main/java/org/jenkinsci/plugins/p4/tagging/TagAction.java . The getRun() method is that in the super class, https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/scm/AbstractScmTagAction.java. However, the stack trace does not show me what code is setting this class's "run" variable.

      The P4 Plugin version is 1.10.9; this had been upgraded from 1.10.6. However, I do not know when this upgrade was made.

        Attachments

          Activity

          Hide
          p4karl Karl Wirth added a comment -

          Hi Annie Chen - Thanks for letting us know.

          Are you saying that you have 3 Perforce builds and only one is failing, or are you saying that all your Perforce builds are failing?

          Please try the following tests:

          • Create a new Perforce job does that work?
          • Try creating a new credential that uses the same userid and password. Switch a failing job to using the new credential does that work?
          • Usually after an upgrade there is a cleanup old data option under Manage Jenkins. Did you run this already?

          Please also give me additional information.

          • Is this a freestyle job?
          • Please send me screenshots showing how the job is defined and any Jenkinsfiles it may be using.

           

          Show
          p4karl Karl Wirth added a comment - Hi Annie Chen - Thanks for letting us know. Are you saying that you have 3 Perforce builds and only one is failing, or are you saying that all your Perforce builds are failing? Please try the following tests: Create a new Perforce job does that work? Try creating a new credential that uses the same userid and password. Switch a failing job to using the new credential does that work? Usually after an upgrade there is a cleanup old data option under Manage Jenkins. Did you run this already? Please also give me additional information. Is this a freestyle job? Please send me screenshots showing how the job is defined and any Jenkinsfiles it may be using.  
          Hide
          danielbeck Daniel Beck added a comment -

          nor has anything been changed on Jenkins except for the version upgrade

           

          What other components besides Jenkins (core) and P4 plugin were updated?

          Show
          danielbeck Daniel Beck added a comment - nor has anything been changed on Jenkins except for the version upgrade   What other components besides Jenkins (core) and P4 plugin were updated?
          Hide
          jenkinsuser1 Annie Chen added a comment -

          Hi Karl Wirth, Daniel Beck,

          Thank you so much for your advice!

          I have several different Perforce builds running on 3 different machines. 2 of the machines are Windows; the other is Linux. The Windows builds still run normally, as do 2 of the 4 Linux builds. It is the other 2 Linux builds that are failing.

          Last Friday, I tried creating a new Perforce job and also creating a new credential with the same userid and password and having the 2 failing jobs use the new credential instead. I did not encounter this NullPointerException again. The new Perforce job works normally. The 2 failing jobs hung, but this seems to be because I ran them at the same time. I stopped those 2 jobs this morning and restarted just 1 of them. It ran normally. I have not tried running the other 1 yet, though it is scheduled to run tonight. In summary, creating a new credential seems to have fixed the problem. Therefore, I think this Bug can be closed. (I can close it if you prefer, but I just wanted to check whether you would like to close it so it shows you handled it.)

          Thank you so much for your help! I really appreciate it!

          Show
          jenkinsuser1 Annie Chen added a comment - Hi Karl Wirth , Daniel Beck , Thank you so much for your advice! I have several different Perforce builds running on 3 different machines. 2 of the machines are Windows; the other is Linux. The Windows builds still run normally, as do 2 of the 4 Linux builds. It is the other 2 Linux builds that are failing. Last Friday, I tried creating a new Perforce job and also creating a new credential with the same userid and password and having the 2 failing jobs use the new credential instead. I did not encounter this NullPointerException again. The new Perforce job works normally. The 2 failing jobs hung, but this seems to be because I ran them at the same time. I stopped those 2 jobs this morning and restarted just 1 of them. It ran normally. I have not tried running the other 1 yet, though it is scheduled to run tonight. In summary, creating a new credential seems to have fixed the problem. Therefore, I think this Bug can be closed. (I can close it if you prefer, but I just wanted to check whether you would like to close it so it shows you handled it.) Thank you so much for your help! I really appreciate it!
          Hide
          p4karl Karl Wirth added a comment -

          Hi Annie Chen - Thanks and I'm happy I could help. If the problem comes back or if there is anything else we can do to help, please let us know.

          Show
          p4karl Karl Wirth added a comment - Hi Annie Chen - Thanks and I'm happy I could help. If the problem comes back or if there is anything else we can do to help, please let us know.
          Hide
          p4karl Karl Wirth added a comment -

          Credential corruption possibly due to another plugin being upgraded. In the past I have seen that saving the credential and then saving the job can solve the problem. In this case recreating the credential seems to have solved the problem.

          Show
          p4karl Karl Wirth added a comment - Credential corruption possibly due to another plugin being upgraded. In the past I have seen that saving the credential and then saving the job can solve the problem. In this case recreating the credential seems to have solved the problem.

            People

            • Assignee:
              Unassigned
              Reporter:
              jenkinsuser1 Annie Chen
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: