Skip to content

Commit c01a99f

Browse files
dmohan200kdvolder
authored andcommitted
[concourse] Add support for set-pipeline step
1 parent f10a6f2 commit c01a99f

File tree

6 files changed

+109
-1
lines changed

6 files changed

+109
-1
lines changed

headless-services/concourse-language-server/src/main/java/org/springframework/ide/vscode/concourse/PipelineYmlSchema.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,12 @@ public PipelineYmlSchema(ConcourseModel models, GithubInfoProvider github) {
365365
taskStep.requireOneOf("config", "file");
366366
taskStep.require(Constraints.implies("vars", "file"));
367367

368+
YBeanType setPipelineStep = f.ybean("SetPipelineStep");
369+
addProp(setPipelineStep, "set_pipeline", t_ne_string);
370+
addProp(setPipelineStep, "file", t_string).isRequired(true);
371+
addProp(setPipelineStep, "vars", t_params);
372+
addProp(setPipelineStep, "var_files", t_strings);
373+
368374
YBeanType aggregateStep = f.ybean("AggregateStep");
369375
YBeanType doStep = f.ybean("DoStep");
370376
YBeanType tryStep = f.ybean("TryStep");
@@ -374,6 +380,7 @@ public PipelineYmlSchema(ConcourseModel models, GithubInfoProvider github) {
374380
getStep,
375381
putStep,
376382
taskStep,
383+
setPipelineStep,
377384
aggregateStep,
378385
inParallelStep,
379386
doStep,
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
*Required* The path to the pipeline's configuration file.
2+
3+
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.
4+
5+
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.
6+
7+
**For example** Fetching and confifuring a pipeline
8+
9+
The `get` step can be used to fetch your configuration from a git repo and auto-configure it using a `set_pipeline` step:
10+
11+
```
12+
- get: ci
13+
- set_pipeline: my-pipeline
14+
file: ci/pipelines/my-pipeline.yml
15+
```
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
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.
2+
3+
*Required* The identifier specifies the name of the pipeline to configure. It will be configured within the current team and be created unpaused.
4+
5+
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
6+
7+
```
8+
resources:
9+
- name: booklit
10+
type: git
11+
source: {uri: https://github.com/vito/booklit}
12+
jobs:
13+
- name: reconfigure
14+
plan:
15+
- get: booklit
16+
trigger: true
17+
- set_pipeline: booklit
18+
file: booklit/ci/pipeline.yml
19+
```
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
*Optional* A map of template variables to pass to the pipeline config.
2+
3+
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.
4+
5+
*Example* Configuring static variables
6+
7+
A var may be statically passed like so:
8+
9+
```
10+
plan:
11+
- get: my-repo
12+
- set_pipeline: configure-the-pipeline
13+
file: my-repo/ci/pipeline.yml
14+
vars:
15+
text: "Hello World!"
16+
```
17+
18+
Any [Vars](https://concourse-ci.org/vars.html) in the pipeline config will be filled in statically using this field.
19+
20+
For example, if my-repo/ci/pipeline.yml looks like...:
21+
22+
```
23+
resources:
24+
- name: task-image
25+
type: docker-image
26+
source:
27+
repository: my.local.registry:8080/my/image
28+
username: ((myuser))
29+
password: ((mypass))
30+
jobs:
31+
- name: job
32+
plan:
33+
- get: task-image
34+
- task: do-stuff
35+
image: task-image
36+
config:
37+
platform: linux
38+
run:
39+
path: echo
40+
args: ["((text))"]
41+
```
42+
43+
...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).

headless-services/concourse-language-server/src/test/java/org/springframework/ide/vscode/concourse/ConcourseEditorTest.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,9 @@ public void primaryStepHovers() throws Exception {
355355
" - in_parallel:\n" +
356356
" - task: perform-something\n" +
357357
" - try:\n" +
358-
" put: test-logs\n"
358+
" put: test-logs\n" +
359+
" - set_pipeline: configure-the-pipeline\n" +
360+
" file: my-repo/ci/pipeline.yml\n"
359361
);
360362

361363
editor.assertHoverContains("get", "Fetches a resource");
@@ -365,6 +367,7 @@ public void primaryStepHovers() throws Exception {
365367
editor.assertHoverContains("task", "Executes a [Task]");
366368
editor.assertHoverContains("do", "performs the given steps serially");
367369
editor.assertHoverContains("try", "Performs the given step, swallowing any failure");
370+
editor.assertHoverContains("set_pipeline", "The identifier specifies the name of the pipeline to configure");
368371
}
369372

370373
@Test
@@ -388,6 +391,26 @@ public void putStepHovers() throws Exception {
388391
editor.assertHoverContains("get_params", "A map of arbitrary configuration to forward to the resource that will be utilized during the implicit `get` step");
389392
}
390393

394+
@Test
395+
public void setPipelineStepHovers() throws Exception {
396+
Editor editor = harness.newEditor(
397+
"jobs:\n" +
398+
"- name: some-job\n" +
399+
" plan:\n" +
400+
" - get: my-repo\n" +
401+
" - set_pipeline: configure-the-pipeline\n" +
402+
" file: my-repo/ci/pipeline.yml\n" +
403+
" var_files:\n" +
404+
" - my-repo/ci/dev.yml\n" +
405+
" vars:\n" +
406+
" text: \"Hello World!\"\n"
407+
);
408+
409+
editor.assertHoverContains("file", "The path to the pipeline's configuration file.");
410+
editor.assertHoverContains("var_files", "files that will be passed to the pipeline config in the same manner as the --load-vars-from flag");
411+
editor.assertHoverContains("vars", "A map of template variables to pass to the pipeline config.");
412+
}
413+
391414
@Test
392415
public void getStepHovers() throws Exception {
393416
Editor editor = harness.newEditor(

0 commit comments

Comments
 (0)