You need to put the parallel in a script section like this (I chnanged the
node tag to 'windows' as I have no executors on the master):
def run = [:]
for (int i = 0; i <= 5; i++) {
println "adding $i"
def currentRun = {
node('windows') {
echo "hello $i"
}
}
run.put("\"test $i\"", currentRun)
}
pipeline {
agent none
stages {
stage('new') {
steps {
script {
parallel(run)
}
}
}
}
}
Also you don't need to do bat "echo" you can just do this, your bat step
failed for me:
echo "hello $i"
--Bill
On Wednesday, 22 March 2017 11:30:40 UTC, Tomas Pekarovic wrote:
>
> 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] echoadding 0[Pipeline] echoadding 1[Pipeline] echoadding
> 2[Pipeline] echoadding 3[Pipeline] echoadding 4[Pipeline] echoadding
> 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 PipelineFinished: 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
>
>
--
You received this message because you are subscribed to the Google Groups
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/b28ec2fe-3a20-40e2-8717-a540d134b99e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.