groovy - how to call a groovy function in an active choice parameter in Jenkins pipeline
问题描述
I have a requirement where user has to select multiple resource names from the input block. I tried active choice parameter inside the user input step, and its working when I hardcode the values but the output is empty when I call a groovy function to dynamically generate the value. This function will return a list of resources names based on the environment passed earlier at the start of the job. So hardcoding the values won't be ideal for my situation. Any ideas on how to call a groovy function into the active choice parameter block?
pipeline {
agent any
stages{
stage('test user input') {
steps {
timestamps {
script {
def userInput = input(
parameters: [[$class: 'ChoiceParameter', choiceType: 'PT_CHECKBOX', description: 'Please select the values', filterLength: 1, filterable: false, name: 'testvalues', randomName: 'choice-parameter-37737065277176157', script: [$class: 'GroovyScript', fallbackScript: [classpath: [], sandbox: false, script: '''return[
\'error\'
]'''], script: [classpath: [], sandbox: false, script: '''def getvalues(){
return[
\'values1\',
\'values2\',
\'values3\',
\'values4\'
]
}
def value=getvalues()
return value''']]]]
)
println("input: " + userInput)
}
}
}
}
}
}
解决方案
推荐阅读
- sql - 为什么 SQL 结果中会出现重复值
- python - 根据python中的优先级列表对数据框列值进行排序
- .net - WebClient.DownloadData 进度报告
- c# - C# 正则表达式获取两个标签之间的文本?
- ios - iOS 系统图标不尊重 UIButton 的 UIImageInsets
- python-3.x - 文件未找到错误:base_library.zip smtp pyinstaller
- typescript - Visual Studio Code 不尊重我的 eslint 报价规则
- jboss - 红帽流程自动化管理器数据库大小调整?
- excel - Worksheet_Change - 捕获对多行中粘贴值的更改
- ios - JSON 字典的 Swift ForEach 问题