3
votes

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

2 Answers

4
votes

The described behavior is now available as of https://issues.jenkins-ci.org/browse/JENKINS-41334 in Pipeline Model Definition Plugin >= 1.2

2
votes

EDIT: This answer is outdated as of October 2017, see @r4d1um's answer.

As of now, declarative pipelines don't support the parallel step directly. This is (according to the roadmap) currently under development:

enter image description here

You have to fall back to scripted pipelines here, either by putting the parallel step into a script { } block, or by wrapping it in a function.