Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-55438

Allow sequential stages inside parallel in Scripted syntax

      Similar to JENKINS-46809, I would like the Blue Ocean GUI to properly visualize multiple stages in sequence that are all parallel of each other. Below is an example image of what this looks like using declarative syntax (working):

       

      Here is the declarative example code I wrote to generate the example image:

      pipeline {
        agent { label 'master' }
        stages {
          stage('Build and Test') {
            parallel {
              stage("Build and Test Linux") {
                stages {
                  stage("Build (Linux)") {
                    agent any
                    steps {
                      echo "Inside for loop 1"
                    }
                  }
                  stage("Test (Linux)") {
                    agent any
                    steps {
                      echo "Inside for loop 2"
                    }
                  }
                }
              }
              stage("Build and Test Windows") {
                stages {
                  stage("Build (Windows)") {
                    agent any
                    steps {
                      echo "Inside for loop 3"
                    }
                  }
                  stage("Test (Windows)") {
                    agent any
                    steps {
                      echo "Inside for loop 4"
                    }
                  }
                }
              }
            }
          }
        }
      }

       

      Here is example scripted Jenkins code that I would like to use. Linux and windows build/test flows happen in parallel. Inside each flow in a "build" stage and then a "test" stage. The Windows sequential build/test flow should be displayed in parallel with the Linux build/test flow, but right now the separate Build/Test sequential stages are combined into one circle/stage when using the scripted syntax.

       

      pipeline {
        agent any
        stages {
          stage("Build and Test") {
            steps {
              script {
                parallel linux: {
                  node("linux_build") {
                    echo "Inside for loop 1"
                  }
                  node("linux_test") {
                    echo "Inside for loop 2"
                  }
                },
                windows: {
                  node("windows_build") {
                    echo "Inside for loop 3"
                  }
                  node("windows_test") {
                    echo "Inside for loop 4"
                  }
                }
              }
            }
          }
        }
      }
      

       

      This is what the scripted example code currently generates:

       

          [JENKINS-55438] Allow sequential stages inside parallel in Scripted syntax

          Adam Carroll created issue -
          Andrew Bayer made changes -
          Component/s New: blueocean-plugin [ 21481 ]
          Component/s Original: pipeline [ 21692 ]
          Component/s Original: pipeline-model-definition-plugin [ 21706 ]
          Andrew Bayer made changes -
          Assignee Original: Andrew Bayer [ abayer ]

          Jesse Glick added a comment -

          First of all, the second example is not Scripted syntax; it is pseudo-Declarative (pipeline) with a script block.

          Second, node is not a stage. Try using the actual stage step.

          If Blue Ocean in fact refuses to display a valid Scripted build with an identical structure of parallel / stage steps that is displayed when run from a Declarative build, then I would consider that a bug rather an RFE.

          Jesse Glick added a comment - First of all, the second example is not Scripted syntax; it is pseudo-Declarative ( pipeline ) with a script block. Second, node is not a stage . Try using the actual stage step. If Blue Ocean in fact refuses to display a valid Scripted build with an identical structure of parallel / stage steps that is displayed when run from a Declarative build, then I would consider that a bug rather an RFE.
          An Tran made changes -
          Attachment New: Screenshot 2019-04-02 at 09.31.50.png [ 46604 ]

          An Tran added a comment - - edited

          I can confirm that I have the same behaviour like that of the author. Only one stage of scripted pipeline in  parallel branches is shown

          pipeline {
            stages {
              stage('testing') {
                steps {
                  script {
                    parallel "task1": {
                        node("ios") {
                          stage("build") {
                              echo "windows-build"
                          }
                          stage("deploy") {
                              echo "windows-deploy"
                          }
                        }
                    },
                    "task2": {
                      node("ios") {
                        stage("build") {
                            echo "windows-build"
                        }
                        stage("deploy") {
                            echo "windows-deploy"
                        }
                      }
                    }
                  }
                }
              }
            }
          }

           

          An Tran added a comment - - edited I can confirm that I have the same behaviour like that of the author. Only one stage of scripted pipeline in  parallel branches is shown pipeline { stages { stage( 'testing' ) { steps { script { parallel "task1" : { node( "ios" ) { stage( "build" ) { echo "windows-build" } stage( "deploy" ) { echo "windows-deploy" } } }, "task2" : { node( "ios" ) { stage( "build" ) { echo "windows-build" } stage( "deploy" ) { echo "windows-deploy" } } } } } } } }  

          Jesse Glick added a comment -

          peacemoon again that is not Scripted syntax. It is a script block inside Declarative syntax.

          Jesse Glick added a comment - peacemoon again that is not Scripted syntax. It is a script block inside Declarative syntax.

          An Tran added a comment -

          jglick Ok, so what is the correct way to do it?

          An Tran added a comment - jglick Ok, so what is the correct way to do it?

          Jesse Glick added a comment -

          I do not know, you would need to experiment.

          Jesse Glick added a comment - I do not know, you would need to experiment.

          An Tran added a comment -

          I did experiment a lot already before asking here

          Ok let's keep the terminology aside.

          Can you help me to understand why only one stage is shown in each parallel branch even though I habe 2 stages for each branch in my script? Is it a bug? Should I create a bug report for that?

          An Tran added a comment - I did experiment a lot already before asking here Ok let's keep the terminology aside. Can you help me to understand why only one stage is shown in each parallel branch even though I habe 2 stages for each branch in my script? Is it a bug? Should I create a bug report for that?

            Unassigned Unassigned
            acarr468 Adam Carroll
            Votes:
            33 Vote for this issue
            Watchers:
            38 Start watching this issue

              Created:
              Updated: