Concourse: support for ensure attribute

This commit is contained in:
Kris De Volder
2016-12-21 10:24:21 -08:00
parent 82a34c4d21
commit 121c8a7c72
4 changed files with 28 additions and 2 deletions

View File

@@ -133,6 +133,7 @@ public class PipelineYmlSchema implements YamlSchema {
// shared properties applicable for any type of Step:
prop(step, "on_success", step);
prop(step, "on_failure", step);
prop(step, "ensure", step);
prop(step, "attempts", t_strictly_pos_integer);
YBeanType resource = f.ybean("Resource");

View File

@@ -1,4 +1,4 @@
Retry a step:
Retry a step.
Any step can set the number of times it should be attempted by attaching an `attempts` parameter with the number of times it should be tried.

View File

@@ -0,0 +1,22 @@
Guarantee execution of a step.
Any step can have `ensure` tacked onto it, whose value is a second step to execute regardless of the result of the parent step.
ensure: step
The step to execute. Regardless of whether the parent step succeeds, fails, or errors, this step will be executed. The step will also be executed if the build was aborted, and its parent step was interrupted.
If the parent step succeeds and the ensured step fails, the parent step is considered to have failed.
The ensured step executes after any `on_success` or `on_failure` hooks.
For example, the following build plan acquires a lock, and then ensures that the lock is released.
plan:
- put: some-lock
params: acquire: true
- task: integration
file: foo/integration.yml
ensure:
put: some-lock
params: release: some-lock

View File

@@ -186,7 +186,9 @@ public class PipelineYamlEditorTest {
" on_failure:\n" +
" - bogus: bad\n" +
" on_success:\n" +
" - bogus: bad\n"
" - bogus: bad\n" +
" ensure:\n" +
" task: cleanups\n"
);
editor.assertHoverContains("resource", "The resource to fetch");
editor.assertHoverContains("version", "The version of the resource to fetch");
@@ -195,6 +197,7 @@ public class PipelineYamlEditorTest {
editor.assertHoverContains("attempts", "Any step can set the number of times it should be attempted");
editor.assertHoverContains("on_failure", "Any step can have `on_failure` tacked onto it");
editor.assertHoverContains("on_success", "Any step can have `on_success` tacked onto it");
editor.assertHoverContains("ensure", "a second step to execute regardless of the result of the parent step");
}
@Test