我需要 jobdsl 语法来获取代码中的密码参数。我尝试了一些语法,但都失败了
eg: password {
name('TEST_ADMIN_USERNAME')
defaultValueAsSecret('foo')
description('User name with the admin privilege')
trim(false)
}
我仍在寻找很长一段时间,只找到一张一年前的票,但仍然没有解决方案“https://github.com/jenkinsci/job-dsl-plugin/pull/1044”
我可以在 dsl wiki 上看到“nonStoredPasswordParam”。仍在弄清楚它是如何工作的。
nonStoredPasswordParam('myParameterName', '我的描述')
如果我们得到任何答案,将关注您的问题。谢谢!
工作DSL:
在作业 DSL 中,您可以使用 nonStoredPasswordParam 来提供密码。
nonStoredPasswordParam
参数由Mask Passwords插件提供,因此也需要安装该插件。参数声明如下所示:
parameters {
nonStoredPasswordParam('TEST_ADMIN_USERNAME', 'User name with the admin privilege')
}
声明式管道:
在
pipeline {}
块中定义的声明性管道中,使用 password
参数显式指定方法参数的名称是可行的。如下所示:
parameters {
password(
name: 'TEST_ADMIN_USERNAME',
description: 'User name with the admin privilege'
)
}