concourse: Add support docs and tests for 'attempts' attribute
This commit is contained in:
@@ -45,6 +45,9 @@ public class PipelineYmlSchema implements YamlSchema {
|
||||
YAtomicType t_boolean = f.yenum("boolean", "true", "false");
|
||||
YAtomicType t_pos_integer = f.yatomic("Positive Integer");
|
||||
t_pos_integer.parseWith(ValueParsers.POS_INTEGER);
|
||||
YAtomicType t_strictly_pos_integer = f.yatomic("Strictly Positive Integer");
|
||||
t_strictly_pos_integer.parseWith(ValueParsers.integerAtLeast(1));
|
||||
|
||||
YType t_any = f.yany("Object");
|
||||
YType t_params = f.ymap(t_string, t_any);
|
||||
YType t_string_params = f.ymap(t_string, t_string);
|
||||
@@ -130,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, "attempts", t_strictly_pos_integer);
|
||||
|
||||
YBeanType resource = f.ybean("Resource");
|
||||
prop(resource, "name", t_ne_string);
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
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.
|
||||
|
||||
attempts: integer
|
||||
|
||||
The total number of times a step should be tried should it fail, e.g. `5` will try the step up to 5 times before giving up.
|
||||
|
||||
When the number of attempts is reached and the step has still not succeeded then the step will fail.
|
||||
|
||||
Attempts will retry on a Concourse error as well as build failure.
|
||||
|
||||
The following will run the task, and retry it 9 times (for a total of 10 attempts) if it fails:
|
||||
|
||||
plan:
|
||||
- get: foo
|
||||
- task: unit
|
||||
file: foo/unit.yml
|
||||
attempts: 10
|
||||
@@ -182,6 +182,7 @@ public class PipelineYamlEditorTest {
|
||||
" params:\n" +
|
||||
" some_param: some_value\n" +
|
||||
" trigger: true\n" +
|
||||
" attempts: 10\n" +
|
||||
" on_failure:\n" +
|
||||
" - bogus: bad\n" +
|
||||
" on_success:\n" +
|
||||
@@ -191,10 +192,11 @@ public class PipelineYamlEditorTest {
|
||||
editor.assertHoverContains("version", "The version of the resource to fetch");
|
||||
editor.assertHoverContains("params", "A map of arbitrary configuration");
|
||||
editor.assertHoverContains("trigger", "Set to `true` to auto-trigger");
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void taskStepHovers() throws Exception {
|
||||
Editor editor = harness.newEditor(
|
||||
@@ -212,6 +214,7 @@ public class PipelineYamlEditorTest {
|
||||
" output_mapping:\n" +
|
||||
" map: of-stuff\n" +
|
||||
" config: some-config\n" +
|
||||
" attempts: 10\n" +
|
||||
" ensure:\n" +
|
||||
" bogus: bad\n" +
|
||||
" on_failure:\n" +
|
||||
@@ -255,13 +258,15 @@ public class PipelineYamlEditorTest {
|
||||
" max_in_flight: -1\n" +
|
||||
" plan:\n" +
|
||||
" - get: git\n" +
|
||||
" trigger: yohoho"
|
||||
" trigger: yohoho\n" +
|
||||
" attempts: 0\n"
|
||||
);
|
||||
editor.assertProblems(
|
||||
"boohoo|boolean",
|
||||
"-1|must be positive",
|
||||
"git|resource does not exist",
|
||||
"yohoho|boolean"
|
||||
"yohoho|boolean",
|
||||
"0|must be at least 1"
|
||||
);
|
||||
|
||||
//check that correct values are indeed accepted
|
||||
|
||||
Reference in New Issue
Block a user