Concourse: basic support for 'try' attribute
This commit is contained in:
@@ -121,17 +121,20 @@ public class PipelineYmlSchema implements YamlSchema {
|
||||
|
||||
YBeanType aggregateStep = f.ybean("AggregateStep");
|
||||
YBeanType doStep = f.ybean("DoStep");
|
||||
YBeanType tryStep = f.ybean("TryStep");
|
||||
|
||||
YBeanType[] stepTypes = {
|
||||
getStep,
|
||||
putStep,
|
||||
taskStep,
|
||||
aggregateStep,
|
||||
doStep
|
||||
doStep,
|
||||
tryStep
|
||||
};
|
||||
YBeanUnionType step = f.yunion("Step", stepTypes);
|
||||
prop(aggregateStep, "aggregate", f.yseq(step));
|
||||
prop(doStep, "do", f.yseq(step));
|
||||
prop(tryStep, "try", step);
|
||||
|
||||
// shared properties applicable for any type of Step:
|
||||
prop(step, "on_success", step);
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
Permit failure of a step.
|
||||
|
||||
try: step
|
||||
|
||||
Performs the given step, swallowing any failure.
|
||||
|
||||
This can be used when you want to perform some side-effect, but you don't really want the whole build to fail if it doesn't work. For example, when emitting logs to S3 for analyzing later, if S3 flakes out it's not too critical.
|
||||
|
||||
plan:
|
||||
- task: run-tests
|
||||
config: # ...
|
||||
on_success:
|
||||
try:
|
||||
put: test-logs
|
||||
from: run-tests/*.log
|
||||
- task: do-something-else
|
||||
config: # ...
|
||||
@@ -118,6 +118,17 @@ public class PipelineYamlEditorTest {
|
||||
"a-single-string|Expecting a 'Sequence'"
|
||||
);
|
||||
|
||||
editor = harness.newEditor(
|
||||
"jobs:\n" +
|
||||
"- name: a-job\n" +
|
||||
" plan:\n" +
|
||||
" - try:\n" +
|
||||
" put: a-resource\n"
|
||||
);
|
||||
editor.assertProblems(
|
||||
"a-resource|does not exist"
|
||||
);
|
||||
|
||||
//TODO: Add more test cases for structural problem?
|
||||
}
|
||||
|
||||
@@ -143,6 +154,9 @@ public class PipelineYamlEditorTest {
|
||||
"put: <*>"
|
||||
, // ==============
|
||||
"task: <*>"
|
||||
, // ==============
|
||||
"try:\n" +
|
||||
" <*>"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -154,14 +168,19 @@ public class PipelineYamlEditorTest {
|
||||
" plan:\n" +
|
||||
" - get: something\n" +
|
||||
" - put: something\n" +
|
||||
" - do: []\n" +
|
||||
" - aggregate:\n" +
|
||||
" - task: do-something\n"
|
||||
" - task: perform-something\n" +
|
||||
" - try:\n" +
|
||||
" put: test-logs\n"
|
||||
);
|
||||
|
||||
editor.assertHoverContains("get", "Fetches a resource");
|
||||
editor.assertHoverContains("put", "Pushes to the given [Resource]");
|
||||
editor.assertHoverContains("aggregate", "Performs the given steps in parallel");
|
||||
editor.assertHoverContains("task", "Executes a [Task]");
|
||||
editor.assertHoverContains("do", "performs the given steps serially");
|
||||
editor.assertHoverContains("try", "Performs the given step, swallowing any failure");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -265,21 +284,6 @@ public class PipelineYamlEditorTest {
|
||||
editor.assertHoverContains("aggregate", "Performs the given steps in parallel");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void doStepHovers() throws Exception {
|
||||
Editor editor;
|
||||
|
||||
editor = harness.newEditor(
|
||||
"jobs:\n" +
|
||||
"- name: some-job\n" +
|
||||
" plan:\n" +
|
||||
" - do:\n" +
|
||||
" - get: some-resource\n"
|
||||
);
|
||||
|
||||
editor.assertHoverContains("do", "performs the given steps serially");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void reconcileSimpleTypes() throws Exception {
|
||||
Editor editor;
|
||||
|
||||
Reference in New Issue
Block a user