How to run multiple stages on the same node with declarative Jenkins pipeline?

后端 未结 4 621
失恋的感觉
失恋的感觉 2021-01-31 02:54

Goal
Run multiple stages of a declarative Jenkins pipeline on the same node.

Setup
This is just a minimal example to show the p

4条回答
  •  北恋
    北恋 (楼主)
    2021-01-31 03:10

    Since version 1.3 of Declarative Pipeline plugin, this is officially supported. It's officially called "Sequential Stages".

    pipeline {
        agent none
    
        stages {
            stage("check code style") {
                agent {
                    docker "code-style-check-image"
                }
                steps {
                    sh "./check-code-style.sh"
                }
            }
    
            stage("build and test the project") {
                agent {
                    docker "build-tools-image"
                }
                stages {
                   stage("build") {
                       steps {
                           sh "./build.sh"
                       }
                   }
                   stage("test") {
                       steps {
                           sh "./test.sh"
                       }
                   }
                }
            }
        }
    }
    

    Official announcement here: https://jenkins.io/blog/2018/07/02/whats-new-declarative-piepline-13x-sequential-stages/

提交回复
热议问题