jenkins-pipeline - Jenkins Groovy Active 选择参数如何将第一个下拉值传递给第二个下拉男孩
问题描述
如何将所选值从第一个下拉列表传递到第二个下拉列表?这是我关注的链接 [链接][1]
// Import the JsonSlurper class to parse Dockerhub API response
import groovy.json.JsonSlurper
// Set the URL we want to read from, it is MySQL from official Library for this example, limited to 20 results only.
docker_image_tags_url = "https://hub.docker.com/v2/repositories/library/mysql/tags/?page_size=20"
try {
// Set requirements for the HTTP GET request, you can add Content-Type headers and so on...
def http_client = new URL(docker_image_tags_url).openConnection() as HttpURLConnection
http_client.setRequestMethod('GET')
// Run the HTTP request
http_client.connect()
// Prepare a variable where we save parsed JSON as a HashMap, it's good for our use case, as we just need the 'name' of each tag.
def dockerhub_response = [:]
// Check if we got HTTP 200, otherwise exit
if (http_client.responseCode == 200) {
dockerhub_response = new JsonSlurper().parseText(http_client.inputStream.getText('UTF-8'))
} else {
println("HTTP response error")
System.exit(0)
}
// Prepare a List to collect the tag names into
def image_tag_list = []
// Iterate the HashMap of all Tags and grab only their "names" into our List
dockerhub_response.results.each { tag_metadata ->
image_tag_list.add(tag_metadata.name)
}
// The returned value MUST be a Groovy type of List or a related type (inherited from List)
// It is necessary for the Active Choice plugin to display results in a combo-box
return image_tag_list.sort()
} catch (Exception e) {
// handle exceptions like timeout, connection errors, etc.
println(e)
}
我有另一个活动的选择框 groovy 脚本,期望从上面的下拉框中得到一个值。我努力了
env = params.mysql_image_version
// def env="dev" // this works but I am hard coding the value ,instead of getting it dynamically from the above dropdown box
env_list.each { env ->
stack_list.add(github_response.get("dev"))
}
print stack_list
解决方案
推荐阅读
- python - 在 Python 中使用正则表达式匹配小时:分钟时间格式
- api - 获取 GoToWebinar 注册人
- angular - Angular Material:我在单击按钮时以 Angular 形式再添加一行 matInput。但 matInput 提交的 UI 未正确加载
- c++ - 用于 Mac 的非 Apple C 编译器
- javascript - 从目录创建对象
- json - json.Unmarshal 忽略 json 字符串中的 json 字符串值,不要尝试解析它
- spring - 我想知道spring-data的命名约定
- html - 如何设置 html“选择”元素的选项位置?
- asynchronous - IRC | 异步通信
- git - heroku App 与带有 git 的 buildpack 不兼容