What do `retry`, `timeout` and `waitUntil` do as steps?
AdvancedConceptDeclarative pipeline syntax
Answer
retry(count: 3, conditions: [agent(), kubernetesAgent(), nonresumable()]) {
sh 'mvn -B deploy'
}
timeout(time: 10, unit: 'MINUTES') { sh './e2e.sh' }
timeout(time: 5, unit: 'MINUTES') {
waitUntil(initialRecurrencePeriod: 5000) {
sh(script: 'curl -fs https://app/healthz', returnStatus: true) == 0
}
}
retry with conditions retries only on infrastructure failures (agent lost, pod deleted), not on real test failures, which is what you want in production.
More on Declarative pipeline syntax
What is the minimum valid declarative pipeline?BeginnerWhat agent types exist in declarative pipelines?IntermediateWhen do you use `agent none` at the top level?IntermediateHow do nested sequential stages work and why are they useful?IntermediateList the `post` conditions and when each fires.IntermediateWhat are the most useful `when` conditions?Intermediate