Is there a way to trigger a retry on a scripted pipeline if the pipeline fails?
properties([
parameters([
string(defaultValue: "", description: 'optional_param1', name: "optional_param1"),
string(defaultValue: "", description: 'optional_param2', name: "optional_param2"),
string(defaultValue: "", description: 'optional_param3', name: "optional_param3"),
]),
pipelineTriggers([cron(cronExpression)]),
])
I see that there are plenty of options for declarative pipeline with options block:
options {
retry (3)
}
and for specific blocks, but I am looking for something that would retry the cronjob if it fails to fire or if the previous build fails.
There is a retry
step that does pretty much the same thing as options { retry }
. Just wrap it around your entire scripted pipeline.
If your cronjob fails to fire (like missing jenkinsfile) then you are SOL, there is no retry for that. Some sort of a dead man switch monitor might alert you, if you set it up, but Jenkins on its own will not retry.