小编Bil*_*fri的帖子

Jenkins 文件中单个阶段内的多个when 子句

我想将多个when 子句放在一个阶段中。这是基本示例

def foo = 0
pipeline {
    agent any

    stages {
        stage('Hello') {
        when {
            expression {foo == 0}
        } 
            steps {
                echo 'foo is 0'
            }
        when {
            expression {foo == 1}
        } 
            steps {
                echo 'foo is 1'
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

当我尝试这个时,我收到一个错误

 Multiple occurrences of the when section 
Run Code Online (Sandbox Code Playgroud)

实际上我真正的问题是不同的,但解决这个问题可能会解决我真正的问题。提前致谢

jenkins

7
推荐指数
1
解决办法
1万
查看次数

标签 统计

jenkins ×1