I want achieve Picture 3. If no need update, give default value. If need update, then give user input area.
I\'d like use active reactive Reference in Jenkins pipeline
Thanks Markzhu;
I ran into the same problem and this solution really helped!
You really don't need to use a Jenkinsfile though. You can just add the code to the reactive parameter like this.
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>"
}
But the better option is to stop using text and use a checkbox instead. Here is how you check the value of a checkbox.
if (NeedUpgradePC.equals('on')){
inputBox="<input name='value' type='text' value='Intel Core i5'>"
} else {
inputBox="<input name='value' type='text' value='Intel Core i5' disabled>"
}
========I made it====== here is the code.
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>"
}
"""
]
]
]
])