Skip to main content

Pipeline - Parallel execution of tasks



  • Serosset Serosset

    Does "parallel" have options to control what happens in case of failure of one of the parallel tasks? What is the default behavior? Fail the "parallel" statement as soon as one of the tasks fail?

    We are using a pipeline job with a combination of "parallel" and downstream jobs, what happens when a downstream job fails? (similar to the example at

  • Pushpa Buzz

    I have used option-1. I am not passing any branch details or anything. Just defined the ubuntu image and running scripts in stage under sh''' .. '''. 

    I see "Failed in branch" and hung the job as well.

    Can you help me?


    [task_1] [Pipeline] [task_1] // stage
    [Pipeline] [task_1] }
    [task_1] Failed in branch task_1
  • Anand Sridharan

    With option1 I am getting the following error

    ERROR: Build step failed with exception groovy.lang.MissingMethodException: No signature of method: Script1.parallel() is applicable for argument types: (java.util.LinkedHashMap) values: [[task_1:Script1$_run_closure1@535b4b7, task_2:Script1$_run_closure2@73eb3b5a]]

    I am running Jenkins 2.89.4 with the latest version of pipeline. I am running this as a "Execute System groovy script" in a job. 


    Executing this code as "Pipeline script" works. I reckon libraries relating to pipeline doesn't load when i execute this as groovy script. 

  • Dineshk7sg Dineshk7sg

    Hi I have 2 questions.

    No 1: Can I create and run tasks individually instead parallel

       - for example  

    def tasks
    tasks["task_1"] = { stage ("task_1"){ node('label_example1') { sh 'echo $NODE_NAME' } } }

    run tasks

    Why I need task to be run separately? - to visualize a task in blue ocean.


    No 2: How can I run parallel stages with multi platform pipeline? below code does. However locking the node is an issue.

    when having the node block inside the stage block in a parallel tasks (why node block inside stage block, because we don't want to create duplicate stage for each task), the node get freed after the first stage and it become available for other jobs. Please find the below code, where the node get occupied by another job after the stage `first`.

    def stages = ["first","second"]
    def tasks = [:]
    for (item in stages) {
      stage (item) {
        tasks["win"] = {
          node(mywinnode) {
            bat 'echo "check"'
        tasks["mac"] = {
          node(mymacnode) {
            sh 'echo "check"'
        parallel task


  • Imran Malik

    Serosset Serosset yes use as `failFast: true` when invoking `parallel`. 


    parallel someparalleltasks, failFast:true 


  • Ramkumar Bangaru

    Is it possible to read the "branchname" inside the closure?


    for example,


    branch["a"] = {

    echo "${branchname}"



    branch["b"] = {

    echo "${branchname}"



    parallel branch




Please sign in to leave a comment.

About CloudBees Support

Our Support Engineers are available to help with any questions or problems you may have with any of our products.