Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,26 @@ podTemplate(containers: […]) {
}
```

### Retrying after infrastructure outages

You can use the `retry` step to automatically try the whole build stage again with a fresh pod in case of fatal infrastructure problems.
(For example: cluster backup & restore; node pool used for agents drained and upgraded.)

```groovy
podTemplate(…) {
retry(count: 2, conditions: [kubernetesAgent(), nonresumable()]) {
node(POD_LABEL) {
sh 'your-build-process'
}
}
}
```

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
(_not_ routine problems such as compilation errors or `OutOfMemoryError`).

For Declarative Pipeline, just add the `retries` option, as shown below.

# Configuration reference
## Pod template

Expand Down Expand Up @@ -588,6 +608,7 @@ pipeline {
- cat
tty: true
'''
retries 2
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this also be set in the Pod Template set in the Clouds configuration?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's great. Thanks. I'm following it.

}
}
stages {
Expand All @@ -612,6 +633,7 @@ pipeline {
agent {
kubernetes {
yamlFile 'KubernetesPod.yaml'
retries 2
}
}
stages {
Expand Down