0

I want to change the value in the Schedule box in Build periodically with parameters in a Jenkins job (see the image) using script in a declarative script while keep everything else the same. enter image description here

Here is what I did:

properties([
        pipelineTriggers([parameterizedCron("H/15 * * * * % VERSION=1.2.3; ENV=prod")])
])

While it successfully change the value that I want but it also remove all other values in Build Trigger (see image) enter image description here

How can I change the value of Build periodically with parameters while keep everything else's setting.

Thank you so much.

1 Answers1

0

Just a wild guess, but I think you created the job and set the triggers in the job's config in the Jenkins UI. Then you added the properties block in the Jenkinsfile. This will overwrite the job config on next execution, so the solution is to add the missing triggers to the properties block in Jenkinsfile.

Jenkins has a build in help go to a PipelineJob and in the left manu ther should be a "Pipeline Syntax" item

enter image description here

SteveiGit
  • 11
  • 5
  • That's what I'm trying to do but I got stuck on how to get the values of all existing triggers. Any idea? – Jack Chung Jul 31 '23 at 23:47
  • Jenkins has a buildin help thing. Go to a pipeline Job, in the left menu there should be a "Pipeline Syntax" link. There you can select the "Declarative Directive Generator" and configure your triggers as in the Job config, but it will give you the code for the pipeline. – SteveiGit Aug 01 '23 at 08:40