Add TaskStep.vars to PipelineYamlSchema
See: https://github.com/spring-projects/sts4/issues/307
This commit is contained in:
@@ -354,10 +354,12 @@ public class PipelineYmlSchema implements YamlSchema {
|
||||
addProp(taskStep, "config", task);
|
||||
addProp(taskStep, "privileged", t_boolean);
|
||||
addProp(taskStep, "params", t_params);
|
||||
addProp(taskStep, "vars", t_params);
|
||||
addProp(taskStep, "image", t_resource_name);
|
||||
addProp(taskStep, "input_mapping", f.ymap(t_ne_string, t_maybe_resource_name));
|
||||
addProp(taskStep, "output_mapping", t_string_params);
|
||||
taskStep.requireOneOf("config", "file");
|
||||
taskStep.require(Constraints.implies("vars", "file"));
|
||||
|
||||
YBeanType aggregateStep = f.ybean("AggregateStep");
|
||||
YBeanType doStep = f.ybean("DoStep");
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
*Optional*. A map of template variables to pass to an external task. Only works with external tasks defined in [`file`](https://concourse-ci.org/task-step.html#task-step-file).
|
||||
|
||||
This is often used in combination with [`((vars))`](https://concourse-ci.org/setting-pipelines.html#pipeline-vars) in the pipeline.
|
||||
|
||||
For example:
|
||||
|
||||
```
|
||||
plan:
|
||||
- get: my-repo
|
||||
- task: integration
|
||||
file: my-repo/ci/task.yml
|
||||
vars:
|
||||
text: ((text))
|
||||
```
|
||||
|
||||
And `task.yml`:
|
||||
|
||||
```
|
||||
---
|
||||
platform: linux
|
||||
|
||||
image_resource:
|
||||
type: docker-image
|
||||
source:
|
||||
repository: my.local.registry:8080/my/image
|
||||
username: ((myuser))
|
||||
password: ((mypass))
|
||||
|
||||
run:
|
||||
path: echo
|
||||
args: ["((text))"]
|
||||
```
|
||||
|
||||
This will resolve `"((text))"` to `"Hello World!"`, while `((myuser))` and `((mypass))` will be resolved at runtime via a [credential manager](https://concourse-ci.org/creds.html), if it has been configured.
|
||||
@@ -465,7 +465,9 @@ public class ConcourseEditorTest {
|
||||
" image: some-image\n" +
|
||||
" params:\n" +
|
||||
" map: of-stuff\n" +
|
||||
" input_mapping:\n" +
|
||||
" vars:\n" +
|
||||
" map: of-stuff\n" +
|
||||
" input_mapping:\n" +
|
||||
" map: of-stuff\n" +
|
||||
" output_mapping:\n" +
|
||||
" map: of-stuff\n" +
|
||||
@@ -484,12 +486,43 @@ public class ConcourseEditorTest {
|
||||
editor.assertHoverContains("privileged", "If set to `true`, the task will run with full capabilities");
|
||||
editor.assertHoverContains("image", "Names an artifact source within the plan");
|
||||
editor.assertHoverContains("params", "A map of task parameters to set, overriding those configured in `config` or `file`");
|
||||
editor.assertHoverContains("vars", "A map of template variables to pass to an external task");
|
||||
editor.assertHoverContains("input_mapping", "A map from task input names to concrete names in the build plan");
|
||||
editor.assertHoverContains("output_mapping", "A map from task output names to concrete names");
|
||||
editor.assertHoverContains("config", "Use `config` to inline the task config");
|
||||
editor.assertHoverContains("tags", "Any step can be directed at a pool of workers");
|
||||
editor.assertHoverContains("timeout", "amount of time to limit the step's execution");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void taskVarsReconcile() throws Exception {
|
||||
Editor editor;
|
||||
|
||||
editor = harness.newEditor(
|
||||
"jobs:\n" +
|
||||
"- name: some-job-with-external-task\n" +
|
||||
" plan:\n" +
|
||||
" - task: do-something\n" +
|
||||
" file: some-file.yml\n" +
|
||||
" vars:\n" +
|
||||
" foo: bar\n"
|
||||
);
|
||||
editor.assertProblems(/*NONE*/);
|
||||
|
||||
editor = harness.newEditor(
|
||||
"jobs:\n" +
|
||||
"- name: some-job-internal-task\n" +
|
||||
" plan:\n" +
|
||||
" - task: do-something\n" +
|
||||
" config: some-config\n" +
|
||||
" vars: not-a-map"
|
||||
);
|
||||
editor.assertProblems(
|
||||
"some-config|Expecting a 'Map'",
|
||||
"vars|assumes that 'file' is also defined",
|
||||
"not-a-map|Expecting a 'Map'"
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aggregateStepHovers() throws Exception {
|
||||
@@ -3734,6 +3767,7 @@ public class ConcourseEditorTest {
|
||||
"→ privileged",
|
||||
"→ tags",
|
||||
"→ timeout",
|
||||
"→ vars",
|
||||
//Completions with '-'
|
||||
"- aggregate",
|
||||
"- do",
|
||||
|
||||
Reference in New Issue
Block a user