Skip to content

Commit d89e521

Browse files
authored
Merge pull request #1282 from jenkinsci/retries-docs
2 parents a55e8ef + c5ad1c0 commit d89e521

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff 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 {

0 commit comments

Comments
 (0)