6
votes

Jenkins pipeline plugin how to run parallel tasks

I am a beginner in jenkins, I want to launch few tasks in parallel on available slave nodes of jenkins using pipeline plugin.

I installed pipeline plugin and added below in the pipeline inline script section.

grovvy script : 
    parallel firstBranch: {
        node('master'){
            echo 'firstBranch'
        }
    }, 
    secondBranch: {
        node('slave1'){
            echo 'secondBranch'
        }
    }

NOTE: master and slave1 are my nodes

What are firstBranch and secondBranch ideally ????

Console output:

Started by user anonymous [Pipeline] parallel [Pipeline] [firstBranch] { (Branch: firstBranch) [Pipeline] [secondBranch] { (Branch: secondBranch) [Pipeline] [firstBranch] node [firstBranch] Running on master in /scratch/gnithyan/.hudson/workspace/pipeline_test
[Pipeline] [secondBranch] node
[Pipeline] [secondBranch] // node
[Pipeline] [secondBranch] }
[secondBranch] Failed in branch secondBranch
[Pipeline] [firstBranch] {
[Pipeline] [firstBranch] echo
[firstBranch] firstBranch
[Pipeline] [firstBranch] }
[Pipeline] [firstBranch] // node
[Pipeline] [firstBranch] }
[Pipeline] // parallel
[Pipeline] End of Pipeline

java.lang.IllegalStateException: cannot start writing logs to a finished node org.jenkinsci.plugins.workflow.cps.nodes.StepStartNode[id=8] at org.jenkinsci.plugins.workflow.support.actions.LogActionImpl.(LogActionImpl.java:110) at org.jenkinsci.plugins.workflow.support.actions.LogActionImpl.stream(LogActionImpl.java:81) at org.jenkinsci.plugins.workflow.support.DefaultStepContext.get(DefaultStepContext.java:73) at org.jenkinsci.plugins.workflow.steps.StepDescriptor.checkContextAvailability(StepDescriptor.java:252) at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:179) at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:126) at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:108) at groovy.lang.GroovyObject$invokeMethod$0.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)

3
please format the code (remove html content) - Jayan
I just starting getting this on a previously working pipeline script w/ the latest version of Jenkins as well. Haven't figured out what the stack dump means yet :-( - kenyee
In the below grovvy script 1.what does firstBranch and secondBranch signifies??? 2.does master and slave1 should be always the name if the available nodes on jenkins?? grovvy script : parallel firstBranch: { node('master'){ echo 'firstBranch' } }, secondBranch: { node('slave1'){ echo 'secondBranch' } } - Goutham Nithyananda

3 Answers

5
votes

I have the same problem. Perhaps I found the depending plugin: https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Supporting+APIs+Plugin See Release Note for Version 2.10 Regression in log handling with certain steps inside parallel in 2.9.

Yes updating the PlugIn works!

1
votes

Seems to be a bug in pipeline api Version 2.9 and will be fixed with 2.10 (see also the release notes https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Supporting+APIs+Plugin)

0
votes

For me, it looks perfectly correct. I had my delivery defined as a pipeline and it worked fine. Today, after updating Jenkins from 2.25 to 2.26 I got the same error. Downgrading to 2.25 didn't help, though, perhaps because I have updated plugins as well :(