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

Allow sequential stages inside parallel in Declarative syntax

    XMLWordPrintable

    Details

    • Sprint:
      Pipeline - April 2018
    • Similar Issues:

      Description

      Currently with -JENKINS-41334-, we set one or more stages to be executed in parallel but no "branches". Meaning that we cannot parallelise a sequence of stages.

       

      Example:

      pipeline {
        agent none
        stages {
          stage('Parallel stuff') {
            parallel 'branch 1' : {
              // Sequencial stages
              stage('Branch 1 stage 1'){
                  agent any
                  steps {
                      echo "In branch 1 stage 1"
                  }
              }
              stage('Branch 1 stage 2'){
                  agent none // With that kind of sequencial stage, we can change the agent to run on
                  steps {
                      sleep 30
                  }
              }
            }, 'branch 2': { // Parallel execution
              stage('Branch 2 stage 1'){
                  agent any
                  steps {
                      echo "In branch 2 stage 1"
                      sleep 60
                  }
              }
            }
          }
        }
      }
      

      Blue ocean possible view:

        Attachments

          Issue Links

            Activity

            Hide
            wknapik wknapik wknapik added a comment -

            Jenn Briden

            can you please give me an example of why you would set up your pipeline that way? Why not create a sibling stage with nested stages? It seems unnecessarily complex.

            The question you should be asking is "why are we creating arbitrary restrictions ?".

            Restricting actual functionality for the sake of easier visualization in Blue Ocean is not an answer you should find acceptable.

            The fact that you see a pipeline as unnecessarily complex doesn't mean that it is, or that it's wrong, or that it should be prohibited.

            If you're having trouble with presentation, look how TeamCity does it - it can present any pipeline you can imagine, with no issues.

            Show
            wknapik wknapik wknapik added a comment - Jenn Briden can you please give me an example of why you would set up your pipeline that way? Why not create a sibling stage with nested stages? It seems unnecessarily complex. The question you should be asking is "why are we creating arbitrary restrictions ?". Restricting actual functionality for the sake of easier visualization in Blue Ocean is not an answer you should find acceptable. The fact that you see a pipeline as unnecessarily complex doesn't mean that it is, or that it's wrong, or that it should be prohibited. If you're having trouble with presentation, look how TeamCity does it - it can present any pipeline you can imagine, with no issues.
            Hide
            adamvoss Adam Voss added a comment -

            Jenn Briden One use reason is to better control the executing node.

            In my example I have a sequential stage where each stage in the sequence may execute on a different node.  One of those stages that I would like to split into two stages, but can only do so if they execute in the same workspace because the second stage will depend on the local output of the first.  If I could have a nested sequential stage, I could define the agent on the nested sequential stage each of its stages would then share that workspace.

            My exiting alternative would be to stash the outputs form the first stage and unstash them on the 2nd, which (untested) seems like a lot more overhead and complexity than I justify for splitting the stage (especially if I were to split it into more than 2 stages).

            Show
            adamvoss Adam Voss added a comment - Jenn Briden One use reason is to better control the executing node. In my example I have a sequential stage where each stage in the sequence may execute on a different node.  One of those stages that I would like to split into two stages, but can only do so if they execute in the same workspace because the second stage will depend on the local output of the first.  If I could have a nested sequential stage, I could define the agent on the nested sequential stage each of its stages would then share that workspace. My exiting alternative would be to stash the outputs form the first stage and unstash them on the 2nd, which (untested) seems like a lot more overhead and complexity than I justify for splitting the stage (especially if I were to split it into more than 2 stages).
            Hide
            olle71 Oliver Santschi added a comment -

            Does this example works for anyone? 

            Do I need a special version for a special plugin?

            Show
            olle71 Oliver Santschi added a comment - Does this example works for anyone?  Do I need a special version for a special plugin?
            Hide
            sheeeng Leonard Lee added a comment -

            Oliver Santschi, please see JENKINS-49050. Also, see this gist.

            Show
            sheeeng Leonard Lee added a comment - Oliver Santschi , please see JENKINS-49050 . Also, see this gist .
            Hide
            horangs Hokwang Lee added a comment -

            Please be interested in this JENKINS-53127 related issue.

            Show
            horangs Hokwang Lee added a comment - Please be interested in this JENKINS-53127 related issue.

              People

              • Assignee:
                abayer Andrew Bayer
                Reporter:
                banst Bastien Arata
              • Votes:
                66 Vote for this issue
                Watchers:
                102 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: