Jenkins Declarative Pipeline parallel stages

Viewed 7291

I know that I can execute steps in parallel using the following Syntax.

pipeline {
  agent any
  stages {
    stage('Build') {
      steps {
        checkout scm
        echo 'Building'
      }
    }
    stage('Some Testing') {
      steps {
        parallel(
          "Step 1": {
            echo 'Step 1'

          },
          "Step 2": {
            echo 'Step 2'

          }
        )
      }
    }
    stage('Send Mail') {
      steps {
        echo "sending mail"
      }
    }
  }
}

I would like to display the steps allone in the Build Overview and move them to their own stages, like this.

pipeline{
    agent any
    stages {
        stage('Build'){
            steps {
                checkout scm
                echo 'Building'
            }
        }
        parallel(
            stage('Step 1'){
                steps{
                    echo 'Step 1'
                }
            }
            stage('Step 2'){
                steps{
                    echo 'Step 2'
                }
            }
        )
        stage('Send Mail'){
            steps {
                echo "sending mail"
            }
        }
    }
}

How can this be achieved, there is no good hint in the Jenkins Documentation regarding pipelines. Or is this just not possible?

Thanks in advance =)

2 Answers
Related