File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -277,6 +277,26 @@ podTemplate(containers: […]) {
277277}
278278```
279279
280+ ### Retrying after infrastructure outages
281+
282+ You can use the ` retry ` step to automatically try the whole build stage again with a fresh pod in case of fatal infrastructure problems.
283+ (For example: cluster backup & restore; node pool used for agents drained and upgraded.)
284+
285+ ``` groovy
286+ podTemplate(…) {
287+ retry(count: 2, conditions: [kubernetesAgent(), nonresumable()]) {
288+ node(POD_LABEL) {
289+ sh 'your-build-process'
290+ }
291+ }
292+ }
293+ ```
294+
295+ will rerun the whole ` node ` block (using the same pod definition) in case the first attempt fails for a qualifying reason traceable to loss of the pod
296+ (_ not_ routine problems such as compilation errors or ` OutOfMemoryError ` ).
297+
298+ For Declarative Pipeline, just add the ` retries ` option, as shown below.
299+
280300# Configuration reference
281301## Pod template
282302
@@ -588,6 +608,7 @@ pipeline {
588608 - cat
589609 tty: true
590610 '''
611+ retries 2
591612 }
592613 }
593614 stages {
@@ -612,6 +633,7 @@ pipeline {
612633 agent {
613634 kubernetes {
614635 yamlFile 'KubernetesPod.yaml'
636+ retries 2
615637 }
616638 }
617639 stages {
You can’t perform that action at this time.
0 commit comments