I want to execute multiple parallel steps in my Jenkins pipeline. All variables I need are given through ArrayLists. Now I want to build the Code via string builder and a for loop. After that I want to execute the String as Code
Pseudocode:
sb << try{ \n
for(i=0; i<TMP; i++) {
sb <<
parallel(
build VARIABLE{
def BUILDJOBNAME = build job: BUILDJOBVARIABLE, parameters:
[
string(name: 'parametername', value: PARAMETER)
]
}
}
sb << catch(e){
(...)
}
But how am I able to execute this? I tried GroovyShell.evaluate(sb.toString()) But this results in the following error:
hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: java.lang.Class.evaluate() is applicable for argument types: (java.lang.String)
GroovyShell.evaluateis an instance method rather than class method. - aristotll