小编Bob*_*der的帖子

隐藏从未在声明性管道中运行的阶段

我有一个脚本化管道,我想将其移植为声明性形式。我曾经有

// Stages used in developement after each single commit
stage('Build') {
}

stage('Unit Tests') {}
// Other stages only for developer
[...]

// Stages used in test only once per day for instance
stage('Deploy') {
    if ( testJob() ) {
    } else {
        Utils.markStageSkippedForConditional(STAGE_NAME)
    }
}
[...]
// Other stages for more testing
Run Code Online (Sandbox Code Playgroud)

然后,对于为开发人员运行的作业,只有管道的第一阶段在 Jenkins 中可见。在声明中,我有:

pipeline {
[...]

    stages {
        stage ('Build') {
            [...]
        }

        stage ('Unit Tests') {
            [...]
        }
[...]        
        stage ('Deploy') {
            when { expression …
Run Code Online (Sandbox Code Playgroud)

visualization declarative jenkins-pipeline

5
推荐指数
1
解决办法
6541
查看次数