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

Change in declarative pipeline behavior with nested docker agents ("java.lang.NullPointerException: Cannot invoke method call() on null object")

XMLWordPrintable

      After upgrading the following plugins:

      junit
      checks-api
      font-awesome-api
      plugin-util-api
      echarts-api
      bootstrap5-api
      jquery3-api
      pipeline-graph-view
      commons-lang3-api
      

      alongside upgrading OpenJDK and rebooting, we began to experience the following errors emitted from our Jenkins pipelines. This error causes an otherwise-successful pipeline to appear as failed, but does not seem to impact the outcome of the job in any way other than how the status is displayed.

      Cannot invoke method call() on null object	
      org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:91)	
      org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:47)	
      org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)	
      org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:34)	
      org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)	
      org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)	
      PluginClassLoader for workflow-cps//com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:20)	
      PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.LoggingInvoker.methodCall(LoggingInvoker.java:118)	
      org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.inDeclarativeAgent(ModelInterpreter.groovy:572)	
      org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.evaluateStage(ModelInterpreter.groovy:276)	
      org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.stageInput(ModelInterpreter.groovy:354)	
      org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.evaluateStage(ModelInterpreter.groovy:265)	
      org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.inWrappers(ModelInterpreter.groovy:592)	
      org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.evaluateStage(ModelInterpreter.groovy:263)	
      org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.withEnvBlock(ModelInterpreter.groovy:432)	
      org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.evaluateStage(ModelInterpreter.groovy:258)	
      ___cps.transform___(Native Method)

       

      In order to reproduce this error, I have traced it down to the following minimal example:

      pipeline {
          agent none
          stages {
              stage("Foo") {
          	    agent {
                      docker {
              	    label "*********"
              	    image "*********"
              	    registryUrl "*********"
              	    registryCredentialsId "*********"
                      } 
          	    }
                  stages {
                      stage("Echo bar") {
                          steps { script { sh "echo bar" } }
                      }
                  }
              }
          }
      } 

      It seems that changing the scope of agent::docker fixes the issue, as the following example pipeline completes without exhibiting this error:

      pipeline {
          agent none
          stages {
              stage("Foo") {
          	    agent { label "*********" }
                  stages {
                      stage("Echo bar") {
                          agent {
                              docker {
                                  reuseNode true
              	            image "*********"
              		    registryUrl "*********"
              		    registryCredentialsId "*********"
              		} 
                          }
                          steps { script { sh "echo bar" } }
                      }
                  }
              }
          }
      } 

      While this is very much not a showstopper (the second minimal example works for our use case), I would be interested in tracing the cause of this change. The first example worked without issue until the upgrade/reboot.

        1. plugins052125.txt
          10 kB
          Baxter
        2. plugins.txt
          6 kB
          Mark Waite
        3. run-jenkins.sh
          0.9 kB
          Mark Waite

            Unassigned Unassigned
            baxter Baxter
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: