【Jenkins pipeline】 参数级联实现
2024-12-08 本文已影响0人
87d6dc4b11a7
安装插件 Active Choices
properties([
parameters([
[$class: "ChoiceParameter",
choiceType: "PT_SINGLE_SELECT",
description: "非直连版本: novlc, 直连版本: vlc",
filterLength: 1,
filterable: false,
name: "CHASSIS_MODE",
script: [
$class: "GroovyScript",
script: [
classpath: [],
sandbox: true,
script:
'''return["vlc","novlc"]'''
]
]
],
[$class: "CascadeChoiceParameter",
choiceType: "PT_SINGLE_SELECT",
description: "branch",
filterLength: 1,
filterable: false,
name: "branch",
referencedParameters: "CHASSIS_MODE",
script: [
$class: "GroovyScript",
script: [
classpath: [],
sandbox: true,
script:
''' if (CHASSIS_MODE.equals("vlc")){
return["orin_mcu_main_dev"]
} else if(CHASSIS_MODE.equals("novlc")){
return["n2a_mcu_platform_dev"]
}
'''
]
]
]
])
])
pipeline {
agent any
stages {
stage ("Example") {
steps {
script{
echo 'Hello'
echo "${params.CHASSIS_MODE}"
echo "${params.branch}"
}
}
}
}
}
https://plugins.jenkins.io/uno-choice/
https://github.com/jenkinsci/active-choices-plugin
https://mirrors.tuna.tsinghua.edu.cn/jenkins/plugins/uno-choice/