Dynamic Parameter in Jenkinsfile?
How can I use the Jenkins Dynamic Plugin in a Jenkinsfile
?
What I am looking for is a Jenkinsfile snippet that:
Build with Parameters
option in the Jenkins job Dynamic Choice Parameters
is populated and the user will see a drop down list. When trying:
Pipeline syntax
in the Jenkins editor properties: Set job properties
as Sample step
This project is parameterized
Dynamic Choice Parameter
Name
, Choice Script
, Remote Script
etc Generate Pipeline Script
I get the following template:
properties([
parameters([
<object of type com.seitenbau.jenkins.plugins.dynamicparameter.ChoiceParameterDefinition>
]),
pipelineTriggers([])
])
ie the generated pipeline script does not contain the data that I have entered in step 5.
above. How can I modify parameters
so that parameter name, choices, etc will be visible to the user?
Jenkins version: 2.19.3 Dynamic Parameter Plugin version: 0.2.0
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:
"anbnc"
If you really need to plugin, then vote on this issue JENKINS-42149.
链接地址: http://www.djcxy.com/p/37228.html下一篇: Jenkinsfile中的动态参数?