如何 enable/disable groovy 脚本中的文本框
how to enable/disable a textbox in groovy script
我的 Jenkins 管道中有几个参数。我的第一个参数是 choice,第二个参数是 Input Box contains string.
我的挑战是,当我 select 第一个参数中的第一个值时,第二个参数(输入框)应该启用,如果不是,则不应该启用。我目前正在为第二个参数使用扩展选择参数,我选择“文本框”作为参数类型。有人可以帮助我了解如何启用和禁用 selecting 不同参数值的参数输入。
例如:
P1 - 选择参数值:启用、禁用
P2 - 扩展选择参数:(文本框)
在这种情况下,P2 必须是 DynamicReferenceParameter,具体取决于 P1。
[$class: 'DynamicReferenceParameter',
choiceType: 'ET_FORMATTED_HTML',
description: '',
name: 'P2',
omitValueField: true,
randomName: 'choice-parameter-123456',
referencedParameters: 'P1',
script: [
$class: 'GroovyScript',
fallbackScript: [
classpath: [],
sandbox: true,
script:
'return [\'Error message\']'
],
script: [
classpath: [],
sandbox: true,
script:
"""
html=""
if (P1.equals("firstValue")){
html="<input name='value' value='' class='setting-input' type='text'>"
}
else {
html="Not applicable"
}
return html
"""
]
] ]
我的 Jenkins 管道中有几个参数。我的第一个参数是 choice,第二个参数是 Input Box contains string.
我的挑战是,当我 select 第一个参数中的第一个值时,第二个参数(输入框)应该启用,如果不是,则不应该启用。我目前正在为第二个参数使用扩展选择参数,我选择“文本框”作为参数类型。有人可以帮助我了解如何启用和禁用 selecting 不同参数值的参数输入。
例如: P1 - 选择参数值:启用、禁用 P2 - 扩展选择参数:(文本框)
在这种情况下,P2 必须是 DynamicReferenceParameter,具体取决于 P1。
[$class: 'DynamicReferenceParameter',
choiceType: 'ET_FORMATTED_HTML',
description: '',
name: 'P2',
omitValueField: true,
randomName: 'choice-parameter-123456',
referencedParameters: 'P1',
script: [
$class: 'GroovyScript',
fallbackScript: [
classpath: [],
sandbox: true,
script:
'return [\'Error message\']'
],
script: [
classpath: [],
sandbox: true,
script:
"""
html=""
if (P1.equals("firstValue")){
html="<input name='value' value='' class='setting-input' type='text'>"
}
else {
html="Not applicable"
}
return html
"""
]
] ]