1

I am using below Groovy Script in Jenkins Pipeline to call a Free style job but it ends up with "No such DSL method 'build'" error.

node{
       def branches = [:] 
       List rows =["Test2", "Test1"] 
       for (int i = 0; i <rows.size(); i++) 
       { 
         def index = i  
         String db = rows[i] 
         branches["branch${i}"] = { 
             build job: 'CopyFile', parameters: [[$class:  
            'StringParameterValue', name:  'DatabaseName', value: db], [$class: 
            'StringParameterValue', name:'dummy', value: "${index}"]] 
       } 
   } 
   parallel branches
}   
7
  • I'm unable to reproduce this, a similar (simplified) versions works as expected for me. Can you add the stacktrace?
    – Jon S
    Feb 8, 2017 at 16:47
  • at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:149) at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:108) at groovy.lang.MetaClassImpl.invokeMethodOnGroovyObject(MetaClassImpl.java:1280) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1174) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1024) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:812) at groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java:46) at groovy.lang.MetaClassImpl.invokeMethodOnGroovyObject(MetaClassImpl.java:1280) Feb 8, 2017 at 17:20
  • at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1174) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1024) 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:18) at WorkflowScript.run(WorkflowScript:18) Feb 8, 2017 at 17:21
  • at ___cps.transform___(Native Method) at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:57) at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:109) at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:82) at sun.reflect.GeneratedMethodAccessor37.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) Feb 8, 2017 at 17:23
  • Umm, unsure what the problem is here. However, it seems like the example above isn't what you are actually running considering WorkflowScript:18 in the stacktrace, e.g. there are at-least 18 lines in the one you run, above script doesn't have 18 lines. Have you tried the script above?
    – Jon S
    Feb 8, 2017 at 17:37

1 Answer 1

4

Installing "Pipeline Build Step Plugin" resolved this issue

https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Build+Step+Plugin

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.