美文网首页
【Jenkins pipeline】 参数级联实现

【Jenkins pipeline】 参数级联实现

作者: 87d6dc4b11a7 | 来源:发表于2024-12-08 15:41 被阅读0次

安装插件 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/

相关文章

网友评论

      本文标题:【Jenkins pipeline】 参数级联实现

      本文链接:https://www.haomeiwen.com/subject/bvsgsjtx.html