小编use*_*263的帖子

Jenkins 管道共享库 - 传递参数

我正在尝试构建一个接受参数以覆盖默认值的函数,但我一直收到“null”。

我写了一个简单的函数:

// vars/Run.groovy
def test(String type, String parallel = 'yes') {
    println(type)
    println(parallel)
}
Run Code Online (Sandbox Code Playgroud)

我的管道如下所示:

node('master') {
    Run.test('unit')
    Run.test('unit', parallel = 'no')
}
Run Code Online (Sandbox Code Playgroud)

我得到的结果是:

unit
yes

unit
null
Run Code Online (Sandbox Code Playgroud)

我错过了什么?

groovy jenkins jenkins-pipeline

4
推荐指数
1
解决办法
2601
查看次数

标签 统计

groovy ×1

jenkins ×1

jenkins-pipeline ×1