Hi all,
I'm trying to change my multiconfiguration project into pipeline. I need to generate parallel steps and than run it.
Can somebody try to help me what am I doing wrong? I just cant figure it out.
====codes===
=============== pipeline =========
def run = [:]
for (int i = 0; i <= 5; i++) {
println "adding $i"
def currentRun = {
node('master') {
bat 'echo "hello $i"'
}
}
run.put("\"test $i\"", currentRun)
}
pipeline {
agent none
stages {
stage('new'){
steps {
echo "${run}"
}
}
}
}
========== output ======================
[Pipeline] echo
adding 0
[Pipeline] echo
adding 1
[Pipeline] echo
adding 2
[Pipeline] echo
adding 3
[Pipeline] echo
adding 4
[Pipeline] echo
adding 5
[Pipeline] stage
[Pipeline] { (new)
[Pipeline] echo
["test 0":org.jenkinsci.plugins.workflow.cps.CpsClosure2@b42371, "test 1":org.jenkinsci.plugins.workflow.cps.CpsClosure2@1fd1631, "test 2":org.jenkinsci.plugins.workflow.cps.CpsClosure2@17e2b9d, "test 3":org.jenkinsci.plugins.workflow.cps.CpsClosure2@8ff06f, "test 4":org.jenkinsci.plugins.workflow.cps.CpsClosure2@1c1669d, "test 5":org.jenkinsci.plugins.workflow.cps.CpsClosure2@af7db5]
[Pipeline] }
[Pipeline] // stage
[Pipeline] End of Pipeline
Finished: SUCCESS
This looks that it should be working, but when I change echo "${run}" to parallel (run) (or parallel ($run) / parallel "$run" etc...)
all i get is:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 16: Nothing to execute within stage "new" @ line 16, column 9.
stage('new'){
^
1 error
at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310)
at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1073)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:591)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:569)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:546)
at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268)
at groovy.lang.GroovyShell.parseClass(GroovyShell.java:688)
at groovy.lang.GroovyShell.parse(GroovyShell.java:700)
at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:67)
at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:430)
at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:393)
at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:238)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:404)
Finished: FAILURE