【发布时间】:2017-09-04 14:07:10
【问题描述】:
我正在使用 Jenkins hidden parameter plugin,但我找不到在 DSL 中编写它的语法,就像我使用其他参数所做的那样。
有没有办法在DSL中体现隐藏参数?
【问题讨论】:
标签: jenkins jenkins-plugins jenkins-pipeline jenkins-job-dsl
我正在使用 Jenkins hidden parameter plugin,但我找不到在 DSL 中编写它的语法,就像我使用其他参数所做的那样。
有没有办法在DSL中体现隐藏参数?
【问题讨论】:
标签: jenkins jenkins-plugins jenkins-pipeline jenkins-job-dsl
Job DSL 没有对 Hidden Parameter 插件的内置支持,因此 API 查看器中没有提到它。但是Automatically Generated DSL支持:
job('example') {
parameters {
wHideParameterDefinition {
name('FOO')
defaultValue('bar')
description('lorem ipsum')
}
}
}
【讨论】:
在使用declarative pipeline syntax(在jenkinsci/pipeline-model-definition-plugin 中描述)之前,您会使用:
但对于 pure DSL pipeline syntax,尚不支持此功能(2017 年 4 月)。
最后一个问题虽然指出JENKINS-29922 (Promote delegates of metasteps to top-level functions, deprecate $class)并添加the comment:
已实现,因此假设为每种凭据类型定义了JENKINS-29922@Symbol,并且凭据步骤标记为 metaStep,您可以更简单地编写:
usernamePassword id: 'hipchat-login', username: 'bob', password: 'abc/def+GHI0123='
hipchat server: …, message: …, credentialsId: 'hipchat-login'
甚至允许生成 id,并从步骤中返回它:
hipchat server: …, message: …, credentialsId: usernamePassword(username: 'bob', password: 'abc/def+GHI0123=')
虽然这是加密的,但并不完全“隐藏”。
【讨论】: