active choice 文档中有提到两个变量jenkinsProject
,jenkinsBuild
,大家一起看下怎么在 script 脚本中使用?我现在的需求是希望可以取到 jenkins 管理的 credentials 帐号密码,当前还没有找到方法。
-
jenkinsProject
-> The Jenkins Project object
-
jenkinsBuild
-> The Jenkins Build object
附上我找到的一些使用方法
properties([
parameters([
[$class: 'ChoiceParameter',
choiceType: 'PT_SINGLE_SELECT',
description: 'Select the Env Name from the Dropdown List',
filterLength: 1,
filterable: false,
name: 'Env',
randomName: 'choice-parameter-5631314439613978',
script: [
$class: 'GroovyScript',
fallbackScript: [
classpath: [],
sandbox: false,
script:
'return[\'Could not get Env\']'
],
script: [
classpath: [],
sandbox: false,
script:
'return["Dev","QA","Stage","Prod"]'
]
]
],
[$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 :
"""
inputBox="<input name='value' type='text' value='Intel Core i5'>"
"""
]
]
],
[$class: 'CascadeChoiceParameter',
choiceType: 'PT_CHECKBOX',
description: 'Select Servers',
filterLength: 1,
filterable: true,
name: 'Server',
randomName: 'choice-parameter-5631314456178619',
referencedParameters: 'Env',
script: [
$class: 'GroovyScript',
fallbackScript: [
classpath: [],
sandbox: false,
script:
'return[\'Could not get Environment from Env Param\']'
],
script: [
classpath: [],
sandbox: false,
script:
''' if (Env.equals("Dev")){
return["devaaa001","devaaa002","devbbb001","devbbb002","devccc001","devccc002"]
}
else if(Env.equals("QA")){
return["qaaaa001","qabbb002","qaccc003"]
}
else if(Env.equals("Stage")){
return["staaa001","stbbb002","stccc003"]
}
else if(Env.equals("Prod")){
return["praaa001","prbbb002","prccc003"]
}
'''
]
]
]
])
//parameters([
// choice(name: "NeedUpgradePC", choices: ['yes', 'no'], description: "Do you need upgrade your PC"),
// [$class : 'DynamicReferenceParameter',
// choiceType : 'ET_FORMATTED_HIDDEN_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>"
// }
// """
// ]
// ]
// ]
//
//])
])