Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins pipeline plugin how to run parallel tasks

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)

like image 970
Goutham Nithyananda Avatar asked Oct 20 '16 10:10

Goutham Nithyananda


People also ask

How do you run parallel builds in Jenkins pipeline?

Choosing which projects to build dynamically based on the repository's structure can be done in 2 steps: Generate the list of projects to be built – We'll use the Pipeline Utility Steps plugin's findFiles function for that. Generate parallel stages based on the list.

How do I run multiple jobs in parallel in Jenkins?

Use mulijob in the following way: When creating new Jenkins jobs you will have an option to create MultiJob project. In the build section, this job can define phases that contain one or more jobs. All jobs that belong to one phase will be executed in parallel (if there are enough executors on the node)

How many jobs can run parallel in Jenkins?

Jenkins can run as many jobs as you have available "executors". You can change the number of executors at will in the configuration.


1 Answers

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!

like image 105
sabf Avatar answered Sep 16 '22 13:09

sabf