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

@NonCPS and @Library not visible in utility classes when used in pipeline model

      It seems that @NonCPS and @Library are not visible in the context of a pipeline model definition and must be fully qualified. ...but to be honest, I have no idea what FQN of this class is. In a "normal" pipeline script, this class is visible by default.

      the error I get is:

       > git config core.sparsecheckout # timeout=10
       > git checkout -f 925b9e05a9e0f6e9717275ad8215e9f07714f38b
       > git rev-list 925b9e05a9e0f6e9717275ad8215e9f07714f38b # timeout=10
      [Pipeline] End of Pipeline
      hudson.remoting.ProxyException: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      file:/home/yooture/hudson_home/jobs/ci/jobs/dummy/builds/90/libs/yooture/src/yooture/jenkins/cloudfoundry/Cloudfoundry.groovy: 214: unable to resolve class NonCPS ,  unable to find class for annotation
       @ line 214, column 1.
         @NonCPS
         ^
      
      file:/home/yooture/hudson_home/jobs/ci/jobs/dummy/builds/90/libs/yooture/src/yooture/jenkins/cloudfoundry/Cloudfoundry.groovy: 220: unable to resolve class NonCPS ,  unable to find class for annotation
       @ line 220, column 1.
         @NonCPS
         ^
      
      2 errors
      
      	at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310)
      	at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:946)
      	at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:593)
      	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:542)
      	at org.codehaus.groovy.control.CompilationUnit$compile$1.call(Unknown Source)
      	at org.jenkinsci.plugins.pipeline.modeldefinition.parser.Converter.compilationUnitToPipelineDef(Converter.groovy:136)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      

          [JENKINS-40642] @NonCPS and @Library not visible in utility classes when used in pipeline model

          Dominik Bartholdi created issue -

          Andrew Bayer added a comment -

          Huh, that's dumb. I should be able to fix that easily.

          Andrew Bayer added a comment - Huh, that's dumb. I should be able to fix that easily.

          Andrew Bayer added a comment -

          Can you get me a reproduction case? I've got a fix, I'm pretty sure, but I need a test. =)

          Andrew Bayer added a comment - Can you get me a reproduction case? I've got a fix, I'm pretty sure, but I need a test. =)
          Andrew Bayer made changes -
          Link New: This issue is duplicated by JENKINS-40640 [ JENKINS-40640 ]
          Andrew Bayer made changes -
          Description Original: It seems that {{@NonCPS}} is not visible in the context of a pipeline model definition and must be fully qualified. ...but to be honest, I have no idea what FQN of this class is. In a "normal" pipeline script, this class is visible by default.

          the error I get is:

          {noformat}
           > git config core.sparsecheckout # timeout=10
           > git checkout -f 925b9e05a9e0f6e9717275ad8215e9f07714f38b
           > git rev-list 925b9e05a9e0f6e9717275ad8215e9f07714f38b # timeout=10
          [Pipeline] End of Pipeline
          hudson.remoting.ProxyException: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
          file:/home/yooture/hudson_home/jobs/ci/jobs/dummy/builds/90/libs/yooture/src/yooture/jenkins/cloudfoundry/Cloudfoundry.groovy: 214: unable to resolve class NonCPS , unable to find class for annotation
           @ line 214, column 1.
             @NonCPS
             ^

          file:/home/yooture/hudson_home/jobs/ci/jobs/dummy/builds/90/libs/yooture/src/yooture/jenkins/cloudfoundry/Cloudfoundry.groovy: 220: unable to resolve class NonCPS , unable to find class for annotation
           @ line 220, column 1.
             @NonCPS
             ^

          2 errors

          at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310)
          at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:946)
          at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:593)
          at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:542)
          at org.codehaus.groovy.control.CompilationUnit$compile$1.call(Unknown Source)
          at org.jenkinsci.plugins.pipeline.modeldefinition.parser.Converter.compilationUnitToPipelineDef(Converter.groovy:136)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          {noformat}
          New: It seems that {{@NonCPS}} and {{@Library}} are not visible in the context of a pipeline model definition and must be fully qualified. ...but to be honest, I have no idea what FQN of this class is. In a "normal" pipeline script, this class is visible by default.

          the error I get is:

          {noformat}
           > git config core.sparsecheckout # timeout=10
           > git checkout -f 925b9e05a9e0f6e9717275ad8215e9f07714f38b
           > git rev-list 925b9e05a9e0f6e9717275ad8215e9f07714f38b # timeout=10
          [Pipeline] End of Pipeline
          hudson.remoting.ProxyException: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
          file:/home/yooture/hudson_home/jobs/ci/jobs/dummy/builds/90/libs/yooture/src/yooture/jenkins/cloudfoundry/Cloudfoundry.groovy: 214: unable to resolve class NonCPS , unable to find class for annotation
           @ line 214, column 1.
             @NonCPS
             ^

          file:/home/yooture/hudson_home/jobs/ci/jobs/dummy/builds/90/libs/yooture/src/yooture/jenkins/cloudfoundry/Cloudfoundry.groovy: 220: unable to resolve class NonCPS , unable to find class for annotation
           @ line 220, column 1.
             @NonCPS
             ^

          2 errors

          at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310)
          at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:946)
          at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:593)
          at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:542)
          at org.codehaus.groovy.control.CompilationUnit$compile$1.call(Unknown Source)
          at org.jenkinsci.plugins.pipeline.modeldefinition.parser.Converter.compilationUnitToPipelineDef(Converter.groovy:136)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          {noformat}
          Summary Original: @NonCPS not visible in utility classes when used in pipeline model New: @NonCPS and @Library not visible in utility classes when used in pipeline model

          Andrew Bayer added a comment -

          Ah, with @Library added in, I've got a test case, so an initial PR is coming momentarily.

          Andrew Bayer added a comment - Ah, with @Library added in, I've got a test case, so an initial PR is coming momentarily.
          Andrew Bayer made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]

          Code changed in jenkins
          User: Andrew Bayer
          Path:
          pipeline-model-definition/pom.xml
          pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/Converter.groovy
          pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/parser/GroovyShellDecoratorImpl.java
          pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/BasicModelDefTest.java
          pipeline-model-definition/src/test/resources/libraryAnnotation.groovy
          http://jenkins-ci.org/commit/pipeline-model-definition-plugin/29da05355dc0bcb543ce376bd07eefd39d8ca10d
          Log:
          [FIXED JENKINS-40642] Add additional imports for parse/translate

          @NonCPS and @Library were the most glaring missing import, but I
          replicated the standard CpsGroovyShell imports - @NonCPS's package,
          hudson.model, jenkins.model, and anything provided by a GroovyShellDecorator.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: pipeline-model-definition/pom.xml pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/Converter.groovy pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/parser/GroovyShellDecoratorImpl.java pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/BasicModelDefTest.java pipeline-model-definition/src/test/resources/libraryAnnotation.groovy http://jenkins-ci.org/commit/pipeline-model-definition-plugin/29da05355dc0bcb543ce376bd07eefd39d8ca10d Log: [FIXED JENKINS-40642] Add additional imports for parse/translate @NonCPS and @Library were the most glaring missing import, but I replicated the standard CpsGroovyShell imports - @NonCPS's package, hudson.model, jenkins.model, and anything provided by a GroovyShellDecorator.

          Liam Newman added a comment -

          Bulk closing resolved issues.

          Liam Newman added a comment - Bulk closing resolved issues.
          Liam Newman made changes -
          Status Original: Resolved [ 5 ] New: Closed [ 6 ]

            abayer Andrew Bayer
            imod Dominik Bartholdi
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: