Jenkins pipeline - parallel stages merging only at

2020-07-30 03:12发布

问题:

I tried looking at the Jenkins pipeline documentation and more importantly the issue JENKINS-38442 before asking this question.

I would like to create a pipeline that looks like this:

Basically, I would like the parallel stages to merge at different stages rather than the next stage itself. Is this possible?

The best I could do so far is only this:

Below is the pipeline code that generated the above pipeline:

node {
   def staticTests = [:]
   staticTests["unit tests"] = {stage('unit'){ }}
   staticTests["static analysis"] = {stage('static'){ }}

   def tests = [:]
   tests["functional"] = {stage('functional'){}}
   tests["performance"] = {stage('performance'){}}
   tests["security"] = {stage('security'){}}

   stage('prepare'){}
   stage('tests'){parallel(staticTests)}
   stage('build'){}
   stage('int'){}
   stage('regression'){}
   stage('qa'){}
   stage('tests'){ parallel(tests) }
   stage('prod'){}
}

What changes will help me to create the pipeline as desired in the modified screenshot pasted above? Is this even possible today with Jenkins pipelines? Thank you for the help in advance!

回答1:

Well you could write

node {
  stage('prepare') {}
  parallel main: {
    stage('unit tests') {}
    stage('build') {}
    stage('int') {}
    stage('regression') {}
    stage('qa') {}
    parallel functional: {}, performance: {}, security: {}
  }, 'static analysis': {}
  stage('prod') {}
}

which will run the way you request (if I understand correctly), but Blue Ocean is not currently able to display it at an appropriate level of detail, as noted in JENKINS-38442.