【问题标题】:Don't allow build if default choice is selected in choice parameter JenkinsDon\'t allow build if default choice is selected in choice parameter Jenkins
【发布时间】:2022-12-02 08:05:51
【问题描述】:

I want to make it function like when ENVIRONMENT is selected as None Build button should not appear or it should not be clickable or should give error live ENVIRONMENT is required!.

@Library('shared-library@main') _

pipeline {
    agent any
    options {
        disableConcurrentBuilds()
        buildDiscarder(logRotator(numToKeepStr: '40', artifactNumToKeepStr: '20'))
    }
    parameters {
        choice(name: 'ENVIRONMENT', choices: ['None','development', 'development2', 'development3', 'development4'], description: 'Environment to be built')
        string(name: 'BRANCH', defaultValue: 'intermediate_release_1.21.0', description: 'Branch to be built')
    }
    stages {
        stage('Repo clone') {
            steps {
                git credentialsId: 'jenkins-automation-github', poll: false, url: 'git@github.com:example/example.git', branch: "${params.BRANCH}"
            }
        }
        stage('Build') {
            steps {
                script{
                    APP_NAME= 'XXX'
                    REPO_NAME= 'XX' + APP_NAME
                    ACCOUNT_ID= 'XXX'
                    ENVIRONMENT = params.BRANCH

                    build(REPO_NAME, ACCOUNT_ID)
                }
            }
        }
    }
}

【问题讨论】:

    标签: jenkins


    【解决方案1】:

    For this you can use the Active Choices Reactive Reference Parameter. Have a look at this.

    【讨论】:

      猜你喜欢
      • 2014-02-12
      • 1970-01-01
      • 2016-01-11
      • 1970-01-01
      • 2022-12-02
      • 2022-12-27
      • 2021-10-04
      • 1970-01-01
      • 2011-12-15
      相关资源
      最近更新 更多