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

Cannot get property 'stages' on null object

XMLWordPrintable

      I have the following simple pipeline:

      @Library("yooture@test")
      import org.foo.Zot
      
      pipeline {
          agent any
          stages {
              stage('Example') {
                  steps {
                      echo 'Hello World'
                  }
              }
          }
          post {
              always {
                  echo 'I will always say Hello again!'
              }
          }
      }
      

      I have the same pipeline in two separate repos in a branch called `develop` (copy/paste).

      In the repo called 'dummy' the job runs fine and the output is like this:

      Started by user Dominik Bartholdi
       > git rev-parse --is-inside-work-tree # timeout=10
      Fetching changes from the remote Git repository
       > git config remote.origin.url git@bitbucket.org:yooture/dummy.git # timeout=10
      Fetching upstream changes from git@bitbucket.org:yooture/dummy.git
       > git --version # timeout=10
      using GIT_SSH to set credentials empty PK to force use of cloudbees dev PK
       > git fetch --tags --progress git@bitbucket.org:yooture/dummy.git +refs/heads/develop
      Checking out Revision bb79c694a8e87299efa63e40e07ead81ca1dafae (develop)
       > git config core.sparsecheckout # timeout=10
       > git checkout -f bb79c694a8e87299efa63e40e07ead81ca1dafae
       > git rev-list bb79c694a8e87299efa63e40e07ead81ca1dafae # timeout=10
      [Bitbucket] Notifying commit build result
      Loading library yooture@test
       > git rev-parse --is-inside-work-tree # timeout=10
      Setting origin to git@bitbucket.org:yooture/yooture-jenkins-pipeline-libraries.git
       > git config remote.origin.url git@bitbucket.org:yooture/yooture-jenkins-pipeline-libraries.git # timeout=10
      Fetching origin...
      Fetching upstream changes from origin
       > git --version # timeout=10
       > git fetch --tags --progress origin +refs/heads/*:refs/remotes/origin/*
       > git rev-parse test^{commit} # timeout=10
       > git rev-parse origin/test^{commit} # timeout=10
       > git rev-parse --is-inside-work-tree # timeout=10
      Fetching changes from the remote Git repository
       > git config remote.origin.url git@bitbucket.org:yooture/yooture-jenkins-pipeline-libraries.git # timeout=10
      Fetching upstream changes from git@bitbucket.org:yooture/yooture-jenkins-pipeline-libraries.git
       > git --version # timeout=10
       > git fetch --tags --progress git@bitbucket.org:yooture/yooture-jenkins-pipeline-libraries.git +refs/heads/*:refs/remotes/origin/*
      Checking out Revision 3ca0c91267dcdad0ca87753530d6ccc72052de6d (test)
       > git config core.sparsecheckout # timeout=10
       > git checkout -f 3ca0c91267dcdad0ca87753530d6ccc72052de6d
       > git rev-list 3ca0c91267dcdad0ca87753530d6ccc72052de6d # timeout=10
      [Bitbucket] Notifying commit build result
      [Pipeline] node
      Still waiting to schedule task
      Waiting for next available executor
      Running on 4301da39 in /scratch/jenkins/workspace/yooture_dummy_develop-4RA5EAL6PUY5FQWEW4F5AGDHPLRE77ZYZYEPJ66GZIF5EPSC45DA
      [Pipeline] {
      [Pipeline] stage
      [Pipeline] { (Declarative: Checkout SCM)
      [Pipeline] checkout
      Cloning the remote Git repository
      Cloning repository git@bitbucket.org:yooture/dummy.git
       > git init /scratch/jenkins/workspace/yooture_dummy_develop-4RA5EAL6PUY5FQWEW4F5AGDHPLRE77ZYZYEPJ66GZIF5EPSC45DA # timeout=10
      Fetching upstream changes from git@bitbucket.org:yooture/dummy.git
       > git --version # timeout=10
      using GIT_SSH to set credentials empty PK to force use of cloudbees dev PK
       > git fetch --tags --progress git@bitbucket.org:yooture/dummy.git +refs/heads/*:refs/remotes/origin/*
       > git config remote.origin.url git@bitbucket.org:yooture/dummy.git # timeout=10
       > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
       > git config remote.origin.url git@bitbucket.org:yooture/dummy.git # timeout=10
      Fetching upstream changes from git@bitbucket.org:yooture/dummy.git
      using GIT_SSH to set credentials empty PK to force use of cloudbees dev PK
       > git fetch --tags --progress git@bitbucket.org:yooture/dummy.git +refs/heads/develop
      Checking out Revision bb79c694a8e87299efa63e40e07ead81ca1dafae (develop)
       > git config core.sparsecheckout # timeout=10
       > git checkout -f bb79c694a8e87299efa63e40e07ead81ca1dafae
      [Bitbucket] Notifying commit build result
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] stage
      [Pipeline] { (Example)
      [Pipeline] echo
      Hello World
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] stage
      [Pipeline] { (Declarative: Post Actions)
      [Pipeline] echo
      I will always say Hello again!
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] End of Pipeline
      [Bitbucket] Notifying commit build result
      [Bitbucket] Build result notified
      Finished: SUCCESS
      

      in the repo called 'yooture' the same pipeline fails with this output:

      Branch indexing
       > git rev-parse --is-inside-work-tree # timeout=10
      Fetching changes from the remote Git repository
       > git config remote.origin.url git@bitbucket.org:yooture/yooture.git # timeout=10
      Fetching upstream changes from git@bitbucket.org:yooture/yooture.git
       > git --version # timeout=10
      using GIT_SSH to set credentials empty PK to force use of cloudbees dev PK
       > git fetch --tags --progress git@bitbucket.org:yooture/yooture.git +refs/heads/develop
      Checking out Revision fb7b7daa3ee2d456edd67b7ec00f944edd969526 (develop)
       > git config core.sparsecheckout # timeout=10
       > git checkout -f fb7b7daa3ee2d456edd67b7ec00f944edd969526
       > git rev-list 449077e7df4f085fd35f284314df4e0ee57ff91c # timeout=10
      [Bitbucket] Notifying commit build result
      Loading library yooture@test
       > git rev-parse --is-inside-work-tree # timeout=10
      Setting origin to git@bitbucket.org:yooture/yooture-jenkins-pipeline-libraries.git
       > git config remote.origin.url git@bitbucket.org:yooture/yooture-jenkins-pipeline-libraries.git # timeout=10
      Fetching origin...
      Fetching upstream changes from origin
       > git --version # timeout=10
       > git fetch --tags --progress origin +refs/heads/*:refs/remotes/origin/*
       > git rev-parse test^{commit} # timeout=10
       > git rev-parse origin/test^{commit} # timeout=10
       > git rev-parse --is-inside-work-tree # timeout=10
      Fetching changes from the remote Git repository
       > git config remote.origin.url git@bitbucket.org:yooture/yooture-jenkins-pipeline-libraries.git # timeout=10
      Fetching upstream changes from git@bitbucket.org:yooture/yooture-jenkins-pipeline-libraries.git
       > git --version # timeout=10
       > git fetch --tags --progress git@bitbucket.org:yooture/yooture-jenkins-pipeline-libraries.git +refs/heads/*:refs/remotes/origin/*
      Checking out Revision 3ca0c91267dcdad0ca87753530d6ccc72052de6d (test)
       > git config core.sparsecheckout # timeout=10
       > git checkout -f 3ca0c91267dcdad0ca87753530d6ccc72052de6d
       > git rev-list d18ccc986483746586e1db7b3b4f09245efd73d8 # timeout=10
      [Bitbucket] Notifying commit build result
      [Pipeline] End of Pipeline
      [Bitbucket] Notifying commit build result
      [Bitbucket] Build result notified
      java.lang.NullPointerException: Cannot get property 'stages' on null object
      	at org.codehaus.groovy.runtime.NullObject.getProperty(NullObject.java:60)
      	at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:172)
      	at org.codehaus.groovy.runtime.callsite.NullCallSite.getProperty(NullCallSite.java:47)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:296)
      	at org.jenkinsci.plugins.pipeline.modeldefinition.Utils.attachDeclarativeActions(Utils.groovy:198)
      	at org.jenkinsci.plugins.pipeline.modeldefinition.Utils$attachDeclarativeActions$7.call(Unknown Source)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
      	at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:18)
      	at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.call(jar:file:/home/yooture/hudson_home/plugins/pipeline-model-definition/WEB-INF/lib/pipeline-model-definition.jar!/org/jenkinsci/plugins/pipeline/modeldefinition/ModelInterpreter.groovy:64)
      	at WorkflowScript.run(WorkflowScript:4)
      	at ___cps.transform___(Native Method)
      	at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:57)
      	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:109)
      	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:82)
      	at sun.reflect.GeneratedMethodAccessor346.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:497)
      	at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
      	at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.get(PropertyishBlock.java:76)
      	at com.cloudbees.groovy.cps.LValueBlock$GetAdapter.receive(LValueBlock.java:30)
      	at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.fixName(PropertyishBlock.java:66)
      	at sun.reflect.GeneratedMethodAccessor350.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:497)
      	at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
      	at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)
      	at com.cloudbees.groovy.cps.Next.step(Next.java:58)
      	at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:154)
      	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
      	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:33)
      	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:30)
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108)
      	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:30)
      	at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:163)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:328)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:80)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:240)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:228)
      	at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:63)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
      	at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	at java.lang.Thread.run(Thread.java:745)
      Finished: FAILURE
      

      As you can see from the commit hashes, the exact same version of the shared library is used: 3ca0c91267dcdad0ca87753530d6ccc72052de6d (test)

      The shared library (branch test) has only one file: src/org/foo/Zot.groovy - but its not even used within the pipeline script.

      package org.foo;
      
      def echo(msg) {
        echo "-> ${msg}"
      }
      

      This is as far as I was able to break down the issue, but now I'm absolutely lost and have no further ideas on how to debug this issue.

            abayer Andrew Bayer
            imod Dominik Bartholdi
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: