[concourse] Add support for set-pipeline step
This commit is contained in:
committed by
Kris De Volder
parent
f10a6f2735
commit
c01a99f3eb
@@ -365,6 +365,12 @@ public class PipelineYmlSchema implements YamlSchema {
|
||||
taskStep.requireOneOf("config", "file");
|
||||
taskStep.require(Constraints.implies("vars", "file"));
|
||||
|
||||
YBeanType setPipelineStep = f.ybean("SetPipelineStep");
|
||||
addProp(setPipelineStep, "set_pipeline", t_ne_string);
|
||||
addProp(setPipelineStep, "file", t_string).isRequired(true);
|
||||
addProp(setPipelineStep, "vars", t_params);
|
||||
addProp(setPipelineStep, "var_files", t_strings);
|
||||
|
||||
YBeanType aggregateStep = f.ybean("AggregateStep");
|
||||
YBeanType doStep = f.ybean("DoStep");
|
||||
YBeanType tryStep = f.ybean("TryStep");
|
||||
@@ -374,6 +380,7 @@ public class PipelineYmlSchema implements YamlSchema {
|
||||
getStep,
|
||||
putStep,
|
||||
taskStep,
|
||||
setPipelineStep,
|
||||
aggregateStep,
|
||||
inParallelStep,
|
||||
doStep,
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
*Required* The path to the pipeline's configuration file.
|
||||
|
||||
file points at a .yml file containing the pipeline configuration, which allows this to be tracked with your resources or generated by a task step.
|
||||
|
||||
The first segment in the path should refer to another artifact from the plan, and the rest of the path is relative to that artifact.
|
||||
|
||||
**For example** Fetching and confifuring a pipeline
|
||||
|
||||
The `get` step can be used to fetch your configuration from a git repo and auto-configure it using a `set_pipeline` step:
|
||||
|
||||
```
|
||||
- get: ci
|
||||
- set_pipeline: my-pipeline
|
||||
file: ci/pipelines/my-pipeline.yml
|
||||
```
|
||||
@@ -0,0 +1,19 @@
|
||||
Note: The `set_pipeline` step was introduced in Concourse v5.8.0. It is considered an experimental feature until its associated [RFC](https://github.com/concourse/rfcs/pull/31) is resolved.
|
||||
|
||||
*Required* The identifier specifies the name of the pipeline to configure. It will be configured within the current team and be created unpaused.
|
||||
|
||||
This is a way to ensure a pipeline stays up to date with its definition in a source code repository, eliminating the need to manually run fly set-pipeline
|
||||
|
||||
```
|
||||
resources:
|
||||
- name: booklit
|
||||
type: git
|
||||
source: {uri: https://github.com/vito/booklit}
|
||||
jobs:
|
||||
- name: reconfigure
|
||||
plan:
|
||||
- get: booklit
|
||||
trigger: true
|
||||
- set_pipeline: booklit
|
||||
file: booklit/ci/pipeline.yml
|
||||
```
|
||||
@@ -0,0 +1 @@
|
||||
*Optional* A list of paths to .yml files that will be passed to the pipeline config in the same manner as the --load-vars-from flag to [fly set-pipeline](https://concourse-ci.org/setting-pipelines.html#fly-set-pipeline). This means that if a variable appears in multiple files, the value from a file that is passed later in the list will override the values from files earlier in the list.
|
||||
@@ -0,0 +1,43 @@
|
||||
*Optional* A map of template variables to pass to the pipeline config.
|
||||
|
||||
Note that variables set with this field will not propagate to tasks configured via task step file. If you want those variables to be determined at the time the pipeline is set, use task step vars as well.
|
||||
|
||||
*Example* Configuring static variables
|
||||
|
||||
A var may be statically passed like so:
|
||||
|
||||
```
|
||||
plan:
|
||||
- get: my-repo
|
||||
- set_pipeline: configure-the-pipeline
|
||||
file: my-repo/ci/pipeline.yml
|
||||
vars:
|
||||
text: "Hello World!"
|
||||
```
|
||||
|
||||
Any [Vars](https://concourse-ci.org/vars.html) in the pipeline config will be filled in statically using this field.
|
||||
|
||||
For example, if my-repo/ci/pipeline.yml looks like...:
|
||||
|
||||
```
|
||||
resources:
|
||||
- name: task-image
|
||||
type: docker-image
|
||||
source:
|
||||
repository: my.local.registry:8080/my/image
|
||||
username: ((myuser))
|
||||
password: ((mypass))
|
||||
jobs:
|
||||
- name: job
|
||||
plan:
|
||||
- get: task-image
|
||||
- task: do-stuff
|
||||
image: task-image
|
||||
config:
|
||||
platform: linux
|
||||
run:
|
||||
path: echo
|
||||
args: ["((text))"]
|
||||
```
|
||||
|
||||
...this will resolve "((text))" to "Hello World!", while ((myuser)) and ((mypass)) will be left in the pipeline to be [fetched at runtime](https://concourse-ci.org/vars.html#dynamic-vars).
|
||||
@@ -355,7 +355,9 @@ public class ConcourseEditorTest {
|
||||
" - in_parallel:\n" +
|
||||
" - task: perform-something\n" +
|
||||
" - try:\n" +
|
||||
" put: test-logs\n"
|
||||
" put: test-logs\n" +
|
||||
" - set_pipeline: configure-the-pipeline\n" +
|
||||
" file: my-repo/ci/pipeline.yml\n"
|
||||
);
|
||||
|
||||
editor.assertHoverContains("get", "Fetches a resource");
|
||||
@@ -365,6 +367,7 @@ public class ConcourseEditorTest {
|
||||
editor.assertHoverContains("task", "Executes a [Task]");
|
||||
editor.assertHoverContains("do", "performs the given steps serially");
|
||||
editor.assertHoverContains("try", "Performs the given step, swallowing any failure");
|
||||
editor.assertHoverContains("set_pipeline", "The identifier specifies the name of the pipeline to configure");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -388,6 +391,26 @@ public class ConcourseEditorTest {
|
||||
editor.assertHoverContains("get_params", "A map of arbitrary configuration to forward to the resource that will be utilized during the implicit `get` step");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setPipelineStepHovers() throws Exception {
|
||||
Editor editor = harness.newEditor(
|
||||
"jobs:\n" +
|
||||
"- name: some-job\n" +
|
||||
" plan:\n" +
|
||||
" - get: my-repo\n" +
|
||||
" - set_pipeline: configure-the-pipeline\n" +
|
||||
" file: my-repo/ci/pipeline.yml\n" +
|
||||
" var_files:\n" +
|
||||
" - my-repo/ci/dev.yml\n" +
|
||||
" vars:\n" +
|
||||
" text: \"Hello World!\"\n"
|
||||
);
|
||||
|
||||
editor.assertHoverContains("file", "The path to the pipeline's configuration file.");
|
||||
editor.assertHoverContains("var_files", "files that will be passed to the pipeline config in the same manner as the --load-vars-from flag");
|
||||
editor.assertHoverContains("vars", "A map of template variables to pass to the pipeline config.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getStepHovers() throws Exception {
|
||||
Editor editor = harness.newEditor(
|
||||
|
||||
Reference in New Issue
Block a user