0
pipeline {
  agent any
  stages {
    stage('Checkout SCM : Some Git repo') 
    {
        steps {
            checkout([$class: 'GitSCM', branches: [[name: 'refs/heads/proj_dev_branch']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CleanBeforeCheckout'], [$class: 'WipeWorkspace']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'credId', refspec: '+refs/heads/proj_dev_branch:refs/remotes/origin/proj_dev_branch', url: 'git@REPO_URL.git']]])
        }
    }


    stage ('Some stage')
    {
        steps {
            sh "echo Something"
            sh 'cat $WORKSPACE/somedir/somefile.txt'
        }
    } 
    }

}

When its with Scripted syntax just works fine, but with declarative one, I am seeing below exception. Does checkout step needs to be wrapped differently?

Started by GitHub push by Running in Durability level: MAX_SURVIVABILITY [Pipeline] Start of Pipeline [Pipeline] End of Pipeline hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: org.jenkinsci.plugins.pipeline.modeldefinition.agent.impl.Any.initialize() is applicable for argument types: (java.util.LinkedHashMap, java.lang.Boolean) values: [[:], false] at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:58) at org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:49) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133) at org.jenkinsci.plugins.pipeline.modeldefinition.model.Agent.getDeclarativeAgent(Agent.groovy:122) 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:498) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42) 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:20) at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.inDeclarativeAgent(ModelInterpreter.groovy:591) at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.call(ModelInterpreter.groovy:78) at WorkflowScript.run(WorkflowScript:1) at cps.transform(Native Method)

vinWin
  • 509
  • 1
  • 5
  • 18
  • Assuming `checkout` is a global var method, you would need to contain it within a `script` block. – Matthew Schuchard Mar 11 '20 at 14:03
  • Thanks @MattSchuchard for response. No luck even with wrapping with `script` block. Not sure what's problem here, as it not pointing to specific line/step/stage. .. Per this : https://jenkins.io/doc/book/pipeline/syntax/#declarative-steps , it does mentions on : _The script step takes a block of Scripted Pipeline and executes that in the Declarative Pipeline. For most use-cases, the script step should be unnecessary in Declarative Pipelines, but it can provide a useful "escape hatch." script blocks of non-trivial size and/or complexity should be moved into Shared Libraries instead._ – vinWin Mar 11 '20 at 14:49
  • Script block is not necessary for `checkout`. You can use any step without script block as long as you don't need to use return values of steps and don't need control structures such as loops. – zett42 Mar 12 '20 at 21:03
  • Can you show your scripted pipeline that works, for comparison? – zett42 Mar 12 '20 at 21:08
  • As we know it's just few small changes for scripted pipeline with `node` replacing `pipeline` and no explicit `stages` block. Figured out the issue & i see it is due to recent `pipeline-* hpi` plugin upgrades & was not considered as corresponding`*.jpi` were taking precedence. Fixed or solved by removing non needed ones & pipeline started working without `scripts` block or any change needed per example. .. Surprisingly Jenkins didn't complained when I visited `Jenkins->Manage Jenkins -> Configure System` section (no plugin errors in red!) – vinWin Mar 13 '20 at 09:46

0 Answers0