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

@Library not working with pipeline model

XMLWordPrintable

      while the following works fine:

      @Library('yooture') 
      import yooture.jenkins.yooture.Yooture
      
      def yoo = new Yooture()
      node {
          yoo.sendChatMessage("hello")
      }
      

      the same definition of a utility library does not work when used in a pipeline model definition:

      @Library('yooture') 
      import yooture.jenkins.yooture.Yooture
      
      def yoo = new Yooture()
      
      pipeline {
        agent any
        stages {
          stage ('prepare') {
            steps {
              script {
                  yoo.sendChatMessage("hello")
              }
            }
          }
        }
      }
      

      it fails with:

       > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
       > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
      Checking out Revision 925b9e05a9e0f6e9717275ad8215e9f07714f38b (refs/remotes/origin/master)
       > 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:
      WorkflowScript: 1: unable to resolve class Library ,  unable to find class for annotation
       @ line 1, column 1.
         @Library('yooture') 
         ^
      
      1 error
      
      	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)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:497)
      	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
      	at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite$StaticMetaMethodSiteNoUnwrapNoCoerce.invoke(StaticMetaMethodSite.java:151)
      	at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.callStatic(StaticMetaMethodSite.java:102)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:206)
      	at org.jenkinsci.plugins.pipeline.modeldefinition.parser.Converter.scriptToPipelineDef(Converter.groovy:116)
      	at org.jenkinsci.plugins.pipeline.modeldefinition.parser.Converter.parseFromCpsScript(Converter.groovy:177)
      	at org.jenkinsci.plugins.pipeline.modeldefinition.parser.Converter$parseFromCpsScript.call(Unknown Source)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
      	at org.jenkinsci.plugins.pipeline.modeldefinition.parser.Converter$parseFromCpsScript.call(Unknown Source)
      	at org.jenkinsci.plugins.pipeline.modeldefinition.Utils.attachExecutionModel(Utils.groovy:183)
      	at org.jenkinsci.plugins.pipeline.modeldefinition.Utils$attachExecutionModel.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:52)
      	at WorkflowScript.run(WorkflowScript:7)
      	at ___cps.transform___(Native Method)
      

            Unassigned Unassigned
            imod Dominik Bartholdi
            Votes:
            2 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated: