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

Can't use milestone with parallel stages in Declarative

      Hello,

      thanks for this  feature - https://jenkins.io/blog/2017/09/25/declarative-1/

      Parallel stages with declarative pipeline.

      We wanted to try parallel, node, milestone together in the particular stage.

      And we tried the below :

      pipeline {
        agent none
        stage('Tests') {
          when { branch 'declarative-pipeline' }
          parallel {
            stage('One') {
              agent any
              steps {
                lock(resource: "${env.JOB_NAME}/10", inversePrecedence: true) {
                  milestone  10
                  node() {
                    deleteDir()
                    execute tests
                  }
                }
              }
            }
          }
        }
      }
      

      but it does not execute this stage and there will be no syntax errors. could you please let me know what is missing in the above example?

      Regards,
      Ashwin

       

       

          [JENKINS-47179] Can't use milestone with parallel stages in Declarative

          Ashwin Y created issue -
          Andrew Bayer made changes -
          Description Original: Hello,

          thanks for this  feature - [https://jenkins.io/blog/2017/09/25/declarative-1/]

          Parallel stages with declarative pipeline.

          We wanted to try parallel, node, milestone together in the particular stage.

          And we tried the below :

           stage('Tests') {
            agent none
            when { branch 'declarative-pipeline' }

          parallel {
                          stage('One') {
                              agent any
                              steps {
                               
                                      lock(resource: "${env.JOB_NAME}/10", inversePrecedence: true) {
                                          milestone 10
                                          emptyNode() {
                                              
                                                  execute tests
                                              }
                                          
                                      }
                                  }
                               
                           }
          }
          }

          but it does not execute this stage and there will be no syntax errors. could you please let me know what is missing in the above example?

          Regards,
          Ashwin

           

           
          New: Hello,

          thanks for this  feature - [https://jenkins.io/blog/2017/09/25/declarative-1/]

          Parallel stages with declarative pipeline.

          We wanted to try parallel, node, milestone together in the particular stage.

          And we tried the below :

          {code}
           stage('Tests') {
            agent none
            when { branch 'declarative-pipeline' }

          parallel {
                          stage('One') {
                              agent any
                              steps {
                               
                                      lock(resource: "${env.JOB_NAME}/10", inversePrecedence: true) {
                                          milestone 10
                                          emptyNode() {
                                              
                                                  execute tests
                                              }
                                          
                                      }
                                  }
                               
                           }
          }
          }
          {code}
          but it does not execute this stage and there will be no syntax errors. could you please let me know what is missing in the above example?

          Regards,
          Ashwin

           

           

          Andrew Bayer added a comment -

          The agent none on the top-level stage shouldn't be there, but it should also be triggering an error. I'm also not sure what your emptyNode() is?

          Andrew Bayer added a comment - The agent none on the top-level stage shouldn't be there, but it should also be triggering an error. I'm also not sure what your emptyNode() is?
          Christopher Fenner made changes -
          Description Original: Hello,

          thanks for this  feature - [https://jenkins.io/blog/2017/09/25/declarative-1/]

          Parallel stages with declarative pipeline.

          We wanted to try parallel, node, milestone together in the particular stage.

          And we tried the below :

          {code}
           stage('Tests') {
            agent none
            when { branch 'declarative-pipeline' }

          parallel {
                          stage('One') {
                              agent any
                              steps {
                               
                                      lock(resource: "${env.JOB_NAME}/10", inversePrecedence: true) {
                                          milestone 10
                                          emptyNode() {
                                              
                                                  execute tests
                                              }
                                          
                                      }
                                  }
                               
                           }
          }
          }
          {code}
          but it does not execute this stage and there will be no syntax errors. could you please let me know what is missing in the above example?

          Regards,
          Ashwin

           

           
          New: Hello,

          thanks for this  feature - [https://jenkins.io/blog/2017/09/25/declarative-1/]

          Parallel stages with declarative pipeline.

          We wanted to try parallel, node, milestone together in the particular stage.

          And we tried the below :
          {code:java}
          stage('Tests') {
            agent none
            when { branch 'declarative-pipeline' }
            parallel {
              stage('One') {
                agent any
                steps {
                  lock(resource: "${env.JOB_NAME}/10", inversePrecedence: true) {
                    milestone 10
                    emptyNode() {
                      execute tests
                    }
                  }
                }
              }
            }
          }
          {code}
          but it does not execute this stage and there will be no syntax errors. could you please let me know what is missing in the above example?

          Regards,
           Ashwin

           

           
          Christopher Fenner made changes -
          Description Original: Hello,

          thanks for this  feature - [https://jenkins.io/blog/2017/09/25/declarative-1/]

          Parallel stages with declarative pipeline.

          We wanted to try parallel, node, milestone together in the particular stage.

          And we tried the below :
          {code:java}
          stage('Tests') {
            agent none
            when { branch 'declarative-pipeline' }
            parallel {
              stage('One') {
                agent any
                steps {
                  lock(resource: "${env.JOB_NAME}/10", inversePrecedence: true) {
                    milestone 10
                    emptyNode() {
                      execute tests
                    }
                  }
                }
              }
            }
          }
          {code}
          but it does not execute this stage and there will be no syntax errors. could you please let me know what is missing in the above example?

          Regards,
           Ashwin

           

           
          New: Hello,

          thanks for this  feature - [https://jenkins.io/blog/2017/09/25/declarative-1/]

          Parallel stages with declarative pipeline.

          We wanted to try parallel, node, milestone together in the particular stage.

          And we tried the below :
          {code:java}
          stage('Tests') {
            agent none
            when { branch 'declarative-pipeline' }
            parallel {
              stage('One') {
                agent any
                steps {
                  lock(resource: "${env.JOB_NAME}/10", inversePrecedence: true) {
                    milestone 10
                    node() {
                      deleteDir()
                      execute tests
                    }
                  }
                }
              }
            }
          }
          {code}
          but it does not execute this stage and there will be no syntax errors. could you please let me know what is missing in the above example?

          Regards,
           Ashwin

           

           

          Hi Andrew, I replaced the emptyNode. We set the agent on parallel stage level to have an own workspace for each parallel execution. Thus we omitted the top level agent.

          Christopher Fenner added a comment - Hi Andrew, I replaced the emptyNode . We set the agent on parallel stage level to have an own workspace for each parallel execution. Thus we omitted the top level agent.
          Christopher Fenner made changes -
          Description Original: Hello,

          thanks for this  feature - [https://jenkins.io/blog/2017/09/25/declarative-1/]

          Parallel stages with declarative pipeline.

          We wanted to try parallel, node, milestone together in the particular stage.

          And we tried the below :
          {code:java}
          stage('Tests') {
            agent none
            when { branch 'declarative-pipeline' }
            parallel {
              stage('One') {
                agent any
                steps {
                  lock(resource: "${env.JOB_NAME}/10", inversePrecedence: true) {
                    milestone 10
                    node() {
                      deleteDir()
                      execute tests
                    }
                  }
                }
              }
            }
          }
          {code}
          but it does not execute this stage and there will be no syntax errors. could you please let me know what is missing in the above example?

          Regards,
           Ashwin

           

           
          New: Hello,

          thanks for this  feature - [https://jenkins.io/blog/2017/09/25/declarative-1/]

          Parallel stages with declarative pipeline.

          We wanted to try parallel, node, milestone together in the particular stage.

          And we tried the below :
          {code:java}

          pipeline {
            agent none
            stage('Tests') {
              when { branch 'declarative-pipeline' }
              parallel {
                stage('One') {
                  agent any
                  steps {
                    lock(resource: "${env.JOB_NAME}/10", inversePrecedence: true) {
                      milestone 10
                      node() {
                        deleteDir()
                        execute tests
                      }
                    }
                  }
                }
              }
            }
          }
          {code}
          but it does not execute this stage and there will be no syntax errors. could you please let me know what is missing in the above example?

          Regards,
           Ashwin

           

           

          The issue here is Using a milestone step inside parallel is not allowed.

          Basically we want to achieve the following behaviour:

          • enter stage
          • wait for lock (LIFO)
          • only proceed if no newer stage has been completed, abort otherwise

          This we do with the lock - milestone combination.

          Christopher Fenner added a comment - The issue here is Using a milestone step inside parallel is not allowed . Basically we want to achieve the following behaviour: enter stage wait for lock (LIFO) only proceed if no newer stage has been completed, abort otherwise This we do with the lock - milestone combination.

          Andrew Bayer added a comment -

          Ah, so the problem is that milestone doesn't work inside parallel - yeah, then it wouldn't work in parallel stages in Declarative either.

          Andrew Bayer added a comment - Ah, so the problem is that milestone doesn't work inside parallel - yeah, then it wouldn't work in parallel stages in Declarative either.

          Before we used it like this in scripted pipelines:

          stage('add. Unit Tests') {
            lock(resource: "${env.JOB_NAME}/20", inversePrecedence: true) {
              milestone 20
              parallel(
                'Test1': {
                  node {
                    deleteDir()
                    execute test
                  }
                }, 'Test2': {
                  node {
                    deleteDir()
                    execute test
                  }
                }, failFast: false
              )
            }
          }
          

          But with declarative this is no longer possible, right?

          Christopher Fenner added a comment - Before we used it like this in scripted pipelines: stage( 'add. Unit Tests' ) { lock(resource: "${env.JOB_NAME}/20" , inversePrecedence: true ) { milestone 20 parallel( 'Test1' : { node { deleteDir() execute test } }, 'Test2' : { node { deleteDir() execute test } }, failFast: false ) } } But with declarative this is no longer possible, right?

            Unassigned Unassigned
            ashsy_009 Ashwin Y
            Votes:
            11 Vote for this issue
            Watchers:
            17 Start watching this issue

              Created:
              Updated: