我有Jenkins pipeline,要求用户选择要部署的实验室,如果选中“Set is developed deployment”(设置已开发部署),则要求pipeline执行其他操作。当尝试在同一阶段下必须多个“when”条件时,它无法运行
pipeline {
parameters {
extendedChoice(name: 'Lab to update', description: 'Select the labs on which you wish to deploy', multiSelectDelimiter: ',',
type: 'PT_CHECKBOX', value: 'lab1,Lab2', visibleItemCount: 5)
extendedChoice(name: 'Set is develop deployment', description: '', multiSelectDelimiter: ',',
type: 'PT_CHECKBOX', value: 'Develop deployment', visibleItemCount: 5)
}
agent { label 'ansible.cyber.local' }
stages {
stage ('Deploy pyspark_dependencies on Lab 1 ') {
when { environment name: 'Lab to update', value: 'Lab1' }
steps {
echo "Stage-1"
}
when { environment name: 'Set is develop deployment', value: 'Develop deployment' }
steps {
echo "Stage-2"
}
}
}
1条答案
按热度按时间m2xkgtsf1#
不能在步骤级别添加when条件。必须将附加步骤移至新阶段或使用if条件。请看以下示例。