Jenkins PipeLine 联动参数
Jenkins PipeLine 联动参数
https://blog.csdn.net/smartvxworks/article/details/137716743
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: true, script: '''return["Could not get Env"]''' ], script: [ classpath: [], sandbox: true, script: '''return["Dev","QA","Stage","Prod"]''' ] ] ], [$class: "CascadeChoiceParameter", choiceType: "PT_SINGLE_SELECT", description: "Select the Server from the Dropdown List", filterLength: 1, filterable: false, name: "Server", randomName: "choice-parameter-5631314456178619", referencedParameters: "Env", script: [ $class: "GroovyScript", fallbackScript: [ classpath: [], sandbox: true, script: '''return["Could not get Environment from Env Param"]''' ], script: [ classpath: [], sandbox: true, 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"] } ''' ] ] ] ]) ]) pipeline { agent any stages { stage ("Example") { steps { script{ echo 'Hello' echo "${params.Env}" echo "${params.Server}" if (params.Server.equals("Could not get Environment from Env Param")) { echo "Must be the first build after Pipeline deployment. Aborting the build" currentBuild.result = 'ABORTED' return } echo "Crossed param validation" } } } } }
出处:http://www.cnblogs.com/lightsong/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接。

浙公网安备 33010602011771号