Fixes #737: on_error support for Steps (Concourse)

This commit is contained in:
Kris De Volder
2022-06-24 10:29:04 -07:00
parent b80fc5d8ba
commit 078d1b1983
3 changed files with 52 additions and 1 deletions

View File

@@ -450,6 +450,7 @@ public class PipelineYmlSchema implements YamlSchema {
addProp(step, subStep, "on_success", step);
addProp(step, subStep, "on_failure", step);
addProp(step, subStep, "on_abort", step);
addProp(step, subStep, "on_error", step);
addProp(step, subStep, "ensure", step);
addProp(step, subStep, "tags", t_strings);
addProp(step, subStep, "timeout", t_duration);

View File

@@ -0,0 +1,17 @@
A hook step to execute after the parent step if the parent step terminates abnormally
in any way other than those handled by the [on_abort](https://concourse-ci.org/on-abort-hook.html#schema.on_abort)
or [on_failure](https://concourse-ci.org/on-failure-hook.html#schema.on_failure).
This covers scenarios as broad as configuration mistakes, temporary network issues with the workers,
or running longer than a timeout.
##Example: Send a notification
```
plan:
- do:
- get: ci
- task: unit
file: ci/unit.yml
on_error:
put: slack
```

View File

@@ -27,7 +27,6 @@ import java.util.stream.Collectors;
import org.eclipse.lsp4j.CompletionItem;
import org.eclipse.lsp4j.Diagnostic;
import org.eclipse.lsp4j.DiagnosticSeverity;
import org.eclipse.lsp4j.DocumentSymbol;
import org.eclipse.lsp4j.InsertTextFormat;
import org.junit.Before;
import org.junit.Ignore;
@@ -74,6 +73,39 @@ public class ConcourseEditorTest {
serverInitializer.setMaxCompletions(100);
}
@Test public void GH_737_support_on_error_in_steps() throws Exception {
//See: https://github.com/spring-projects/sts4/issues/737
Editor editor = harness.newEditor(
"jobs:\n" +
"- name: myjob\n" +
" serial: false\n" +
" plan:\n" +
" - task: build-app\n" +
" params:\n" +
" STAGE: dev\n" +
" APP: app\n" +
" file: build.xml\n" +
" on_success:\n" +
" put: buildstatus\n" +
" params:\n" +
" context: build\n" +
" repo: src\n" +
" state: SUCCESSFUL\n" +
" on_error:\n" +
" put: buildstatus\n" +
" params:\n" +
" context: build\n" +
" repo: src\n" +
" state: FAILED"
);
editor.assertProblems(
"buildstatus|does not exist",
"buildstatus|does not exist"
);
editor.assertHoverContains("on_error", "execute after the parent step if the parent step terminates abnormally");
}
@Test public void GH_752_accross_step_modifier() throws Exception {
//See: https://github.com/spring-projects/sts4/issues/752
//See: https://concourse-ci.org/across-step.html#schema.across
@@ -4685,6 +4717,7 @@ public class ConcourseEditorTest {
"→ image",
"→ input_mapping",
"→ on_abort",
"→ on_error",
"→ on_failure",
"→ on_success",
"→ output_mapping",