屬性([gitLabConnection(gitLabConnection:'GitLab Connection',jobCredentialId:''),[$class:'GitlabLogoProperty',repositoryName:''],引數([extendedChoice(multiSelectDelimiter:',',名稱:'choice',quoteValue : false, saveJSONParameterToFile: false, type: 'PT_CHECKBOX', value: 'mongo, mysql', visibleItemCount: 10)])])
管道 { 代理任何在此處輸入影像描述
stages {
stage('mongo') {
when {
expression { choice == 'mongo' }
}
steps {
echo "${params.choice}"
}
}
stage('mysql') {
when {
expression { choice == 'mysql' }
}
steps {[enter image description here][1]
echo "${params.choice}"
}
}
}
}
當我同時選擇 mongo 和 mysql 復選框時,兩個階段都應該作業,但 mongo 和 mysql 都被跳過
uj5u.com熱心網友回復:
我無法在宣告性管道中設定擴展選擇引數。相反,我使用了布爾引數。請參閱以下內容了解您的用例。注意我已經宣告了一個名為choice 的全域變數。
def choice = ""
pipeline {
agent any
stages {
stage("Get details") {
steps{
timeout(time: 300, unit: 'SECONDS') {
script {
// Select the product image
choice = input message: 'Please select the product', ok: 'Build',
parameters: [
booleanParam(defaultValue: false, name: 'mongo'),
booleanParam(defaultValue: false, name: 'mysql')]
}
}
}
}
stage('Echo') {
steps {
script {
echo "::: Product : ${choice}"
}
}
}
stage('mongo') {
when {
expression { return choice.get("mongo") }
}
steps {
echo "MONGO"
}
}
stage('mysql') {
when {
expression { return choice.get("mysql") }
}
steps {
echo "MYSQL"
}
}
}
post {
success {
echo 'The process is successfully Completed....'
}
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/489944.html
