Declarative parallel stages

163 views
Skip to first unread message

Jakub Pawlinski

unread,
Jul 11, 2017, 10:10:37 AM7/11/17
to Jenkins Users
In Blue Ocean 1.1.4 I have tried everything from and some own ideas, nothing seems to work:

stages {

  stage('Parallel1') { 
    parallel 'branch1': {
      node('n1') { stage('Unit 1') { echo "1" }
    }, 'branch2': {
      node('n2') { stage('Unit 2') { echo "2" }
    }
  }
}
* Result: Starting with version 0.5, steps in a stage must be in a steps block

stages {
  steps {
    parallel 'branch1': { 
      node('n1') { stage('Unit 1') { echo "1" } } 
    }, 'branch2': {
      node('n2') { stage('Unit 2') { echo "2" } }
    }
  }
}
* Result: Invalid step "stage" used - not allowed in this context - The stage step cannot be used in Declarative Pipelines

The only working version I have is:
        stage ('Parallel1') {
            steps {
                parallel ("TEST A" : {
                    echo "TEST A"
                },"TEST A" : {
                    echo "TEST B"
                })
            }
        }

but this gives parallel steps not stages -- less readability and lack of control like:
        stage ('TEST A') {
            when {
                expression { params.DO_TEST_A == true }
            }
            steps {
                echo "TEST A"
            }
        }

Any ideas how to make it work?
Reply all
Reply to author
Forward
0 new messages