Dynamic Parameter in Jenkinsfile?

前端 未结 1 1419
天命终不由人
天命终不由人 2021-01-17 12:16

How can I use the Jenkins Dynamic Plugin in a Jenkinsfile?

What I am looking for is a Jenkinsfile snippet that:

  • Enables the Build wi
1条回答
  •  北海茫月
    2021-01-17 12:50

    there is no need anymore for the Jenkins Dynamic Plugin anymore. Just use the normal choice or string parameter and have the value(s) updated by groovy code.

    #!/bin/groovy
    
    def envs = loadEnvs();
    
    properties([
       parameters([
          choice(choices: envs, description: 'Please select an environment', name: 'Env')
       ])
    ])
    
    node { 
       try {
          stage('Preparation'){
    ...
    

    If you use the choice parameter be aware the you must provide a string where the values are separated by a new line.

    For example:

    "a\nb\nc"
    

    If you really need to plugin, then vote on this issue JENKINS-42149.

    0 讨论(0)
提交回复
热议问题