Overview:
I am trying to checkout the github code in my multi-configuration jenkins pipeline:
package checkout void call() { println "checkout stage..." node { deleteDir() checkout scm } }
I am using JTE (Jenkins Template Engine)
ISSUE:
But jenkins complains error Step checkout from the library checkout does not have the method call(GitSCM)
after building the pipeline. Please find the stacktrace below:
hudson.remoting.ProxyException: org.boozallen.plugins.jte.binding.TemplateException: Step checkout from the library checkout does not have the method call(GitSCM)
at org.boozallen.plugins.jte.binding.injectors.StepWrapper.invoke(script1596520065305271654461.groovy:98)
at org.boozallen.plugins.jte.binding.injectors.StepWrapper.call(script1596520065305271654461.groovy:60)
at checkout.script15965200672531305703678.call(script15965200672531305703678.groovy:19)
at ___cps.transform___(Native Method)
at sun.reflect.GeneratedConstructorAccessor515.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:83)
at org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:77)
at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrap.callConstructor(ConstructorSite.java:84)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:60)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:235)
at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.constructorCall(DefaultInvoker.java:25)
at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:97)
at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:83)
at sun.reflect.GeneratedMethodAccessor632.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.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:107)
at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:83)
at sun.reflect.GeneratedMethodAccessor632.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.ContinuationGroup.methodCall(ContinuationGroup.java:89)
at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:113)
at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:83)
at sun.reflect.GeneratedMethodAccessor632.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)
As I am new in groovy and Jenkins, I would appreciate it if you could share any genuine solution or idea.
I found my issues and will post it here to be used by newbies like me:
I needed to do following changes and rerun the jenkins build to fix the issue:
Move the node
keyword to the template jenkinsfile in /templates/jenkinsfile
node('<executer node>') { scm_checkout() }
Update the pipeline_config.groovy file in /templates/
directory:
libraries { merge = true scm_checkout }
Update the library directory name to scm_checkout. the directory and file name should be different form checkout to avoid referring the checkout(scm)
to the wrong lib.
The checkout lib should in libraries/scm_checkout/scm_checkout.groovy
and the content is like below:
void call() { println "checkout stage..." deleteDir() def checkout = checkout(scm) }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.