Jack Chung
Jack Chung

Reputation: 1

Update the value of parameterizedCron from the Jenkins Declarative Script

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.

Upvotes: 0

Views: 546

Answers (1)

SteveiGit
SteveiGit

Reputation: 11

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

Upvotes: 0

Related Questions