How do piping options and jenkins gui options work together?

I am using pipeline in jenkins file and I am not sure how to properly link work in Jenkins and pipeline.

I have defined the parameters in my jenkinsfile (some with defaults, some without ) and initialize them from the parameters coming from the jenkins gui. The problem is that it flattens the parameters in my pipeline, overriding my job settings, EVEN when no default is specified in the pipeline , which means that the pipeline is overriding my job setting in jenkins.

for example one of my jobs is setting up to run the pipeline with some specific values ​​(everything is NOT-EMPTY), if I run the job, the pipeline looks like reset to properties '' for fields b and c.

How can I get the pipeline not to touch the jenkins job definition?

eg. parameters in the pipeline:

    properties([
      parameters([
        string(name: 'a',   defaultValue: 'Default A value', description: '', ),
        string(name: 'b',   description: '', ),
        string(name: 'c',   description: '', ),
       ])
])

      

I didn't find any help in the documentation at https://jenkins.io/doc/book/pipeline/syntax/#parameters-example

+3


source to share


1 answer


Oh, yes, this is also the first time.

The first time you run the pipeline, the jenkinsFile DSL job definition pretty much overrides any job definition that you entered through the GUI. This affects the parameters in particular.



So make sure you define the parameters exactly how you want them in the Jenkinsfile, then do one job and the GUI will have the same configuration for the parameters, so that when you run it again it will ask for the parameters and use the default values ​​that you specified in the DSL ... There is nothing more.

Yes, you have to run twice every time you change the parameters in the DSL, annoying. But it makes sense if you think the job needs to be done to evaluate the DSL, but it needs to set parameters first, if you have certain values ​​through the UI, before it checks and evaluates the DSL ...

+3


source







All Articles