Jenkins根据条件更改构建参数UI

时间:2020-04-27 16:54:26

标签: jenkins jenkins-pipeline jenkins-plugins jenkins-groovy jenkins-shared-libraries

我正在使用Jenkins共享库来构建带有构建参数的作业。默认情况下,构建参数为文本字段,即我们可以修改值,例如,在以下代码段中,我们可以修改构建参数 manifestId

现在,我需要添加另一个参数 buildBranch ,但这可以是可编辑的文本字段,也可以是不可编辑的。当我们在 branch_name 变量中具有特定值(例如release /)时,此build参数应该不可编辑,否则应类似于manifestId一样可编辑。

我正在研究Jenkins Active-Choices-Plugin反应参考参数。想知道如何将条件放入参数块中。任何帮助深表感谢。

def call(HashMap pipelineParams = [:]) {
    String branch_name= params.buildBranch ?: BRANCH_NAME

    pipeline {
        parameters {
            string(defaultValue: "", description: 'ManifestId', name: 'manifestId', trim: true)
            //how to make it non-editable when we have specific value of branch_name, as defined above
             string(defaultValue: branch_name, description: 'buildBranch', name: 'buildBranch', trim: true)
        }
        agent { label 'miscslave' }
        stages {
            stage(){
                script{}
                script{}
            }
        }

0 个答案:

没有答案
相关问题