我想要实现图3。如果不需要更新,给默认值。如果需要更新,则给用户输入区域。
我想在 Jenkins 管道代码中使用主动反应参考,而不是 jenkins GUI。检查了示例,但用户不能自己输入值,只能提供选择。正如我们所看到的 Jenkins GUI 图 1 和 2 可以使用“格式化 HTML”来做到这一点,但是我们如何在管道中使用它或将其转换为管道?
========我成功了======这是代码。
parameters([
choice(name:"NeedUpgradePC",choices:['yes','no'],description: "Do you need upgrade your PC"),
[$class: 'DynamicReferenceParameter',
choiceType: 'ET_FORMATTED_HTML',
omitValueField: true,
description: 'Please provide a Elastic alias label',
name: 'PC_RAM',
randomName: 'choice-parameter-5631314456178624',
referencedParameters: 'NeedUpgradePC',
script: [
$class: 'GroovyScript',
fallbackScript: [
classpath: [],
sandbox: true,
script:
'return[\'nothing.....\']'
],
script: [
classpath: [],
sandbox: true,
script:
"""
if(NeedUpgradePC.equals('yes')) {
inputBox="<input name='value' type='text' value='Kingston 8GB'>"
} else {
inputBox="<input name='value' type='text' value='Kingston 8GB' disabled>"
}
"""
]
]
],
[$class: 'DynamicReferenceParameter',
choiceType: 'ET_FORMATTED_HTML',
omitValueField: true,
description: 'Please provide a Elastic alias label',
name: 'PC_CPU',
randomName: 'choice-parameter-5631314456178624',
referencedParameters: 'NeedUpgradePC',
script: [
$class: 'GroovyScript',
fallbackScript: [
classpath: [],
sandbox: true,
script:
'return[\'nothing.....\']'
],
script: [
classpath: [],
sandbox: true,
script:
"""
if(NeedUpgradePC.equals('yes')) {
inputBox="<input name='value' type='text' value='Intel Core i5'>"
} else {
inputBox="<input name='value' type='text' value='Intel Core i5' disabled>"
}
"""
]
]
]
])
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13499 次 |
| 最近记录: |