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

Nullpointer: Cannot get property 'stages' on null object

    XMLWordPrintable

Details

    Description

      Up to version 0.3 pipeline could be wrapped by timestamps from the timestamps plugin which was really neat. This doesn't work anymore and causes a Nullpointer.

      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.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:302)
      	at org.jenkinsci.plugins.pipeline.modeldefinition.Utils.attachExecutionModel(Utils.groovy:202)
      	at org.jenkinsci.plugins.pipeline.modeldefinition.Utils$attachExecutionModel$4.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:16)
      	at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.call(jar:file:/var/jenkins_home/plugins/pipeline-model-definition/WEB-INF/lib/pipeline-model-definition.jar!/org/jenkinsci/plugins/pipeline/modeldefinition/ModelInterpreter.groovy:51)
      	at WorkflowScript.run(WorkflowScript:7)
      	at ___cps.transform___(Native Method)
      	at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:48)
      	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.GeneratedMethodAccessor347.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	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.GeneratedMethodAccessor349.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	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:324)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:78)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:236)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:224)
      	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)
      

      Attachments

        Issue Links

          Activity

            bitwiseman Liam Newman added a comment -

            Bulk closing resolved issues.

            bitwiseman Liam Newman added a comment - Bulk closing resolved issues.

            I can confirm it is working now by adding

              wrappers {
                timestamps()
              }
            
            pleibiger Peter Leibiger added a comment - I can confirm it is working now by adding wrappers { timestamps() }
            abayer Andrew Bayer added a comment -

            Merged, will be released in 0.5.

            abayer Andrew Bayer added a comment - Merged, will be released in 0.5.

            Code changed in jenkins
            User: Andrew Bayer
            Path:
            pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/ModelParser.groovy
            pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/ValidatorTest.java
            pipeline-model-definition/src/test/resources/errors/pipelineStepWithinOtherBlocksFailure.groovy
            http://jenkins-ci.org/commit/pipeline-model-definition-plugin/4c9cb6df95d606dc02bf747d91f6e0e00f2ee4f6
            Log:
            Merge pull request #33 from abayer/jenkins-39011

            [FIXED JENKINS-39011] Error out at parse time when pipeline step is n…

            Compare: https://github.com/jenkinsci/pipeline-model-definition-plugin/compare/abbde740b9b6...4c9cb6df95d6

            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/ModelParser.groovy pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/ValidatorTest.java pipeline-model-definition/src/test/resources/errors/pipelineStepWithinOtherBlocksFailure.groovy http://jenkins-ci.org/commit/pipeline-model-definition-plugin/4c9cb6df95d606dc02bf747d91f6e0e00f2ee4f6 Log: Merge pull request #33 from abayer/jenkins-39011 [FIXED JENKINS-39011] Error out at parse time when pipeline step is n… Compare: https://github.com/jenkinsci/pipeline-model-definition-plugin/compare/abbde740b9b6...4c9cb6df95d6

            Code changed in jenkins
            User: Andrew Bayer
            Path:
            pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/ModelParser.groovy
            pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/ValidatorTest.java
            pipeline-model-definition/src/test/resources/errors/pipelineStepWithinOtherBlocksFailure.groovy
            http://jenkins-ci.org/commit/pipeline-model-definition-plugin/f25d40a2a5ffe0469ce80b070610d07fcdd3bb2a
            Log:
            [FIXED JENKINS-39011] Error out at parse time when pipeline step is nested.

            We don't want to support nesting the pipeline step within other blocks

            • until JENKINS-38152, we never noticed that this was actually
              possible, since the parse-time validation just ignored any Jenkinsfile
              without a root-level pipeline step, but with JENKINS-38152, we not
              only do another parse round but need to grab the stages from the model
              to attach to the run, so we hit an NPE when there's a pipeline step
              nested under other blocks.

            So - this will now catch when the pipeline step is nested within
            another block and give an error message at parse-time, rather than
            NPEing at runtime. There is a valid use case for wanting to wrap the
            entire build in something like a timeout or timestamper, but we're
            going to address that with JENKINS-37823.

            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/ModelParser.groovy pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/ValidatorTest.java pipeline-model-definition/src/test/resources/errors/pipelineStepWithinOtherBlocksFailure.groovy http://jenkins-ci.org/commit/pipeline-model-definition-plugin/f25d40a2a5ffe0469ce80b070610d07fcdd3bb2a Log: [FIXED JENKINS-39011] Error out at parse time when pipeline step is nested. We don't want to support nesting the pipeline step within other blocks until JENKINS-38152 , we never noticed that this was actually possible, since the parse-time validation just ignored any Jenkinsfile without a root-level pipeline step, but with JENKINS-38152 , we not only do another parse round but need to grab the stages from the model to attach to the run, so we hit an NPE when there's a pipeline step nested under other blocks. So - this will now catch when the pipeline step is nested within another block and give an error message at parse-time, rather than NPEing at runtime. There is a valid use case for wanting to wrap the entire build in something like a timeout or timestamper, but we're going to address that with JENKINS-37823 .
            abayer Andrew Bayer added a comment -

            PR up - https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/33 - this doesn't allow the previous use case, but it does start catching this at parse-time, as it should have previously. I'll get moving on the wrapper addition ASAP as well.

            abayer Andrew Bayer added a comment - PR up - https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/33 - this doesn't allow the previous use case, but it does start catching this at parse-time, as it should have previously. I'll get moving on the wrapper addition ASAP as well.
            abayer Andrew Bayer added a comment -

            Interesting - it makes sense that it wouldn't work (if you've got the pipeline step in your Pipeline, other steps won't work outside it) but it does need error reporting. And we need https://issues.jenkins-ci.org/browse/JENKINS-37823 so that you can actually use timestamper. =)

            abayer Andrew Bayer added a comment - Interesting - it makes sense that it wouldn't work (if you've got the pipeline step in your Pipeline, other steps won't work outside it) but it does need error reporting. And we need https://issues.jenkins-ci.org/browse/JENKINS-37823 so that you can actually use timestamper . =)

            People

              abayer Andrew Bayer
              pleibiger Peter Leibiger
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: