【问题标题】:multiple boolean parameters in declarative pipeline声明性管道中的多个布尔参数
【发布时间】:2022-06-20 21:10:10
【问题描述】:

我有一个案例,我需要在 jenkins 的声明性管道中使用复选框参数和字符串参数,每个复选框代表 url

parameters {

  booleanParam(defaultValue: false, name: 'https://test1.com', description: 'Non-Prod' )

  booleanParam(defaultValue: false, name: 'https://test2.com', description: 'Non-Prod'

  booleanParam(defaultValue: false, name: 'https://test3.com', description: 'Prod')

  string(name: 'user', defaultValue: '')

}

我只想遍历具有真值的复选框(选中),并且我需要根据布尔参数的描述执行某些步骤

【问题讨论】:

  • 将它们重构为单个 list 参数可能会容易得多。

标签: jenkins-pipeline jenkins-declarative-pipeline


【解决方案1】:

我可以通过以下方式做到这一点:

stages {
stage('Create Account') {
steps {
script {
params.keySet().each {
if ( params."${it}" && it.matches("https(.*)")) {
--- }

【讨论】:

    猜你喜欢
    • 2019-06-01
    • 1970-01-01
    • 2019-03-18
    • 1970-01-01
    • 2018-05-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-17
    相关资源
    最近更新 更多