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

Nasty compilation failure when post doesn't contain name/closure blocks

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      For a post section like this:

      post {
          archive '**/*.hpi'
          junit '**/*.xml'
      }
      

      ...you get an error like this:

      BUG! exception in phase 'canonicalization' in source unit 'WorkflowScript' unexpected NullpointerException
      	at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1058)
      	at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:591)
      	at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:569)
      	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:546)
      	at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298)
      	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268)
      	at groovy.lang.GroovyShell.parseClass(GroovyShell.java:688)
      	at groovy.lang.GroovyShell.parse(GroovyShell.java:700)
      	at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:67)
      	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:411)
      	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:374)
      	at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:220)
      	at hudson.model.ResourceController.execute(ResourceController.java:98)
      	at hudson.model.Executor.run(Executor.java:410)
      Caused by: java.lang.NullPointerException
      	at org.jenkinsci.plugins.structs.SymbolLookup$Key.hashCode(SymbolLookup.java:144)
      	at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:936)
      	at org.jenkinsci.plugins.structs.SymbolLookup.find(SymbolLookup.java:47)
      	at org.jenkinsci.plugins.structs.SymbolLookup$find$0.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 org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
      	at org.jenkinsci.plugins.pipeline.modeldefinition.validator.ModelValidatorImpl.validateElement(ModelValidatorImpl.groovy:146)
      	at org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTBuildCondition.validate(ModelASTBuildCondition.java:27)
      	at org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTBuildConditionsContainer.validate(ModelASTBuildConditionsContainer.java:40)
      	at org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTPostBuild.validate(ModelASTPostBuild.java:31)
      	at org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTPipelineDef.validate(ModelASTPipelineDef.java:72)
      	at org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTPipelineDef$validate.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 org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
      	at org.jenkinsci.plugins.pipeline.modeldefinition.parser.ModelParser.parse(ModelParser.groovy:207)
      	at org.jenkinsci.plugins.pipeline.modeldefinition.parser.ModelParser$parse.callCurrent(Unknown Source)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
      	at org.jenkinsci.plugins.pipeline.modeldefinition.parser.ModelParser.parse(ModelParser.groovy:108)
      	at org.jenkinsci.plugins.pipeline.modeldefinition.parser.GroovyShellDecoratorImpl$1.call(GroovyShellDecoratorImpl.java:38)
      	at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1053)
      	... 13 more
      

      We should be putting all SymbolLookup.get().find(...) calls in try/catch blocks and handling them more elegantly.

        Attachments

          Issue Links

            Activity

            Show
            abayer Andrew Bayer added a comment - PR up at https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/56
            Hide
            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/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidatorImpl.groovy
            pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/ValidatorTest.java
            pipeline-model-definition/src/test/resources/errors/badPostContent.groovy
            http://jenkins-ci.org/commit/pipeline-model-definition-plugin/bfc38f958d33fa9115fa1d357504f58a8174ec10
            Log:
            [FIXED JENKINS-39799] Properly handle bad content in post blocks.

            We actually would have errored out properly-ish if it wasn't for the
            fact that we ended up with a ModelASTBuildCondition with null
            condition and null branch, leading to the NPE during compilation. I
            decided to improve the error messaging and make sure we don't attempt
            to validate further when condition or branch are null.

            Show
            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/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidatorImpl.groovy pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/ValidatorTest.java pipeline-model-definition/src/test/resources/errors/badPostContent.groovy http://jenkins-ci.org/commit/pipeline-model-definition-plugin/bfc38f958d33fa9115fa1d357504f58a8174ec10 Log: [FIXED JENKINS-39799] Properly handle bad content in post blocks. We actually would have errored out properly-ish if it wasn't for the fact that we ended up with a ModelASTBuildCondition with null condition and null branch, leading to the NPE during compilation. I decided to improve the error messaging and make sure we don't attempt to validate further when condition or branch are null.

              People

              • Assignee:
                abayer Andrew Bayer
                Reporter:
                abayer Andrew Bayer
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: