Skip to content
This repository was archived by the owner on Mar 21, 2025. It is now read-only.

Commit e947609

Browse files
author
Michael Sauter
authored
Merge pull request #601 from opendevstack/feature/multiple-event-triggers
Support multiple pipelines triggered by different events
2 parents c853996 + 53aab77 commit e947609

29 files changed

+1157
-232
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ listed in the changelog.
1313

1414
- Stream Buildah and Aqua log output ([#596](https://github.com/opendevstack/ods-pipeline/issues/596))
1515
- Update skopeo (1.6 to 1.8) and buildah (1.24 to 1.26) ([#598](https://github.com/opendevstack/ods-pipeline/issues/598))
16+
- Support running different pipelines on different webhook events (current `ods.yaml` format still supported for the moment, but will be deprecated and removed in upcoming releases) ([#562](https://github.com/opendevstack/ods-pipeline/issues/562))
1617

1718
### Fixed
1819

docs/add-to-repository.adoc

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,32 +27,32 @@ environments:
2727
stage: dev
2828
2929
pipeline:
30-
tasks:
31-
- name: backend-build-go
32-
taskRef:
33-
kind: Task
34-
name: ods-build-go-v0-6-0
35-
workspaces:
36-
- name: source
37-
workspace: shared-workspace
38-
- name: backend-package-image
39-
taskRef:
40-
kind: Task
41-
name: ods-package-image-v0-6-0
42-
runAfter:
43-
- backend-build-go
44-
workspaces:
45-
- name: source
46-
workspace: shared-workspace
47-
- name: backend-deploy
48-
taskRef:
49-
kind: Task
50-
name: ods-deploy-helm-v0-6-0
51-
runAfter:
52-
- backend-package-image
53-
workspaces:
54-
- name: source
55-
workspace: shared-workspace
30+
- tasks:
31+
- name: backend-build-go
32+
taskRef:
33+
kind: Task
34+
name: ods-build-go-v0-6-0
35+
workspaces:
36+
- name: source
37+
workspace: shared-workspace
38+
- name: backend-package-image
39+
taskRef:
40+
kind: Task
41+
name: ods-package-image-v0-6-0
42+
runAfter:
43+
- backend-build-go
44+
workspaces:
45+
- name: source
46+
workspace: shared-workspace
47+
- name: backend-deploy
48+
taskRef:
49+
kind: Task
50+
name: ods-deploy-helm-v0-6-0
51+
runAfter:
52+
- backend-package-image
53+
workspaces:
54+
- name: source
55+
workspace: shared-workspace
5656
----
5757

5858
The only Go specific task is `ods-build-go-v0-6-0`, if you use another technology, exchange the task for another one such as `ods-build-gradle-v0-5-1`.

docs/authoring-tasks.adoc

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ Normally, a Tekton task is a Kubernetes resource in your OpenShift project. Howe
2424
[source,yaml]
2525
----
2626
pipeline:
27-
tasks:
28-
- name: hello-world
29-
taskSpec:
30-
steps:
31-
- name: say-hello
32-
image: busybox
33-
script: |
34-
echo hello world
35-
workspaces:
36-
- name: source
37-
workspace: shared-workspace
27+
- tasks:
28+
- name: hello-world
29+
taskSpec:
30+
steps:
31+
- name: say-hello
32+
image: busybox
33+
script: |
34+
echo hello world
35+
workspaces:
36+
- name: source
37+
workspace: shared-workspace
3838
----
3939

4040
== Creating your own task
@@ -66,11 +66,11 @@ Your `ods.yaml` file would reference this task like this:
6666
[source,yaml]
6767
----
6868
pipeline:
69-
tasks:
70-
- name: hello-world
71-
taskRef:
72-
kind: Task
73-
name: hello-world
69+
- tasks:
70+
- name: hello-world
71+
taskRef:
72+
kind: Task
73+
name: hello-world
7474
----
7575

7676
Of course this doesn't do anything useful in the CI pipeline. Typically, you'd need to mount a workspace (containing the Git repository you are working in) and maybe offer some parameters to the user of this task. Have a look at the official ODS tasks for more sophisticated examples of existing tasks. Later on in this document we'll look at some example tasks you could create.

docs/convert-quickstarter-component.adoc

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -97,32 +97,32 @@ environments:
9797
stage: dev
9898
9999
pipeline:
100-
tasks:
101-
- name: backend-build-go
102-
taskRef:
103-
kind: Task
104-
name: ods-build-go-v0-6-0
105-
workspaces:
106-
- name: source
107-
workspace: shared-workspace
108-
- name: backend-package-image
109-
taskRef:
110-
kind: Task
111-
name: ods-package-image-v0-6-0
112-
runAfter:
113-
- backend-build-go
114-
workspaces:
115-
- name: source
116-
workspace: shared-workspace
117-
- name: backend-deploy
118-
taskRef:
119-
kind: Task
120-
name: ods-deploy-helm-v0-6-0
121-
runAfter:
122-
- backend-package-image
123-
workspaces:
124-
- name: source
125-
workspace: shared-workspace
100+
- tasks:
101+
- name: backend-build-go
102+
taskRef:
103+
kind: Task
104+
name: ods-build-go-v0-6-0
105+
workspaces:
106+
- name: source
107+
workspace: shared-workspace
108+
- name: backend-package-image
109+
taskRef:
110+
kind: Task
111+
name: ods-package-image-v0-6-0
112+
runAfter:
113+
- backend-build-go
114+
workspaces:
115+
- name: source
116+
workspace: shared-workspace
117+
- name: backend-deploy
118+
taskRef:
119+
kind: Task
120+
name: ods-deploy-helm-v0-6-0
121+
runAfter:
122+
- backend-package-image
123+
workspaces:
124+
- name: source
125+
workspace: shared-workspace
126126
----
127127

128128
What has been done in Jenkins in `stageCheckFormat`, `stageLint`, `stageUnitTest`, `stageBuild` and `odsComponentStageScanWithSonar` is now done by the `ods-build-go-v0-6-0` task. If you have modified how the application is tested and built, or added further steps, you will need to create your own Tekton tasks reflecting those changes. See the link:authoring-tasks.adoc[authoring tasks] guide.

docs/design/software-design-specification.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ Upgrades (or installs) a Helm chart.
426426

427427
| SDS-PIPELINE-MANAGER-4
428428
| `pipeline-manager` binary
429-
a| The pipeline manager parses the JSON payload and handles `repo:refs_changed` and `pr:opened` events. Other events are dropped.
429+
a| The pipeline manager parses the JSON payload and triggers a pipeline run dependent on the events received.
430430

431431
For Git commits of which the commit message instructs skipping CI, no pipelines are triggered. Instructions may be anywhere in the commit message and may be one of (case-insensitive):
432432

docs/design/software-requirements-specification.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ The tasks shall create artifacts of their work. Those artifacts shall be stored
8888

8989
| SRS-PIPELINE-MANAGER-6
9090
| The pipeline manager shall prevent concurrent pipeline runs for one repository.
91+
92+
| SRS-PIPELINE-MANAGER-7
93+
| The pipeline manager shall be able trigger different pipelines dependent on the configured events.
9194
|===
9295

9396
=== Tasks Requirements

docs/example-project.adoc

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -29,32 +29,32 @@ environments:
2929
stage: dev
3030
3131
pipeline:
32-
tasks:
33-
- name: build
34-
taskRef:
35-
kind: Task
36-
name: ods-build-go-v0-6-0
37-
workspaces:
38-
- name: source
39-
workspace: shared-workspace
40-
- name: package
41-
taskRef:
42-
kind: Task
43-
name: ods-package-image-v0-6-0
44-
runAfter:
45-
- build
46-
workspaces:
47-
- name: source
48-
workspace: shared-workspace
49-
- name: deploy
50-
taskRef:
51-
kind: Task
52-
name: ods-deploy-helm-v0-6-0
53-
runAfter:
54-
- package
55-
workspaces:
56-
- name: source
57-
workspace: shared-workspace
32+
- tasks:
33+
- name: build
34+
taskRef:
35+
kind: Task
36+
name: ods-build-go-v0-6-0
37+
workspaces:
38+
- name: source
39+
workspace: shared-workspace
40+
- name: package
41+
taskRef:
42+
kind: Task
43+
name: ods-package-image-v0-6-0
44+
runAfter:
45+
- build
46+
workspaces:
47+
- name: source
48+
workspace: shared-workspace
49+
- name: deploy
50+
taskRef:
51+
kind: Task
52+
name: ods-deploy-helm-v0-6-0
53+
runAfter:
54+
- package
55+
workspaces:
56+
- name: source
57+
workspace: shared-workspace
5858
----
5959

6060
todo-frontend/.ods.yaml
@@ -70,32 +70,32 @@ environments:
7070
stage: dev
7171
7272
pipeline:
73-
tasks:
74-
- name: build
75-
taskRef:
76-
kind: Task
77-
name: ods-build-npm-v0-6-0
78-
workspaces:
79-
- name: source
80-
workspace: shared-workspace
81-
- name: package
82-
taskRef:
83-
kind: Task
84-
name: ods-package-image-v0-6-0
85-
runAfter:
86-
- build
87-
workspaces:
88-
- name: source
89-
workspace: shared-workspace
90-
- name: deploy
91-
taskRef:
92-
kind: Task
93-
name: ods-deploy-helm-v0-6-0
94-
runAfter:
95-
- package
96-
workspaces:
97-
- name: source
98-
workspace: shared-workspace
73+
- tasks:
74+
- name: build
75+
taskRef:
76+
kind: Task
77+
name: ods-build-npm-v0-6-0
78+
workspaces:
79+
- name: source
80+
workspace: shared-workspace
81+
- name: package
82+
taskRef:
83+
kind: Task
84+
name: ods-package-image-v0-6-0
85+
runAfter:
86+
- build
87+
workspaces:
88+
- name: source
89+
workspace: shared-workspace
90+
- name: deploy
91+
taskRef:
92+
kind: Task
93+
name: ods-deploy-helm-v0-6-0
94+
runAfter:
95+
- package
96+
workspaces:
97+
- name: source
98+
workspace: shared-workspace
9999
----
100100

101101
Both pipelines are almost identical, only the build task differs. Both repositories have a webhook configured, pointing to the event listener in the `todo-cd` namespace.
@@ -130,14 +130,14 @@ environments:
130130
stage: qa
131131
132132
pipeline:
133-
tasks:
134-
- name: deploy
135-
taskRef:
136-
kind: ClusterTask
137-
name: ods-deploy-helm-v0-6-0
138-
workspaces:
139-
- name: source
140-
workspace: shared-workspace
133+
- tasks:
134+
- name: deploy
135+
taskRef:
136+
kind: ClusterTask
137+
name: ods-deploy-helm-v0-6-0
138+
workspaces:
139+
- name: source
140+
workspace: shared-workspace
141141
----
142142

143143
When a commit is pushed into the `release/1.0.0` branch, a deploy is triggerd into the `todo-qa` project. The deployment uses the chart defined in the `chart` directory of the `todo-app` repository. That chart does not contain any resource templates itself, as all Kubernetes resources are defined in the charts in the components `todo-backend` and `todo-frontend`. However, the umbrella chart has to supply values which are specific to the "qa" environment. This can be done via a `values.qa.yaml` file. Values in that file can set values for dependencies (like the `backend` component) by nesting the values under the respective key, as shown in the following example. Assume we have the following `values.yaml` file in the `todo-backend` application:

docs/introduction.adoc

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -68,32 +68,32 @@ To understand how this works, it is best to trace the flow starting from the rep
6868
[source,yml]
6969
----
7070
pipeline:
71-
tasks:
72-
- name: build-go
73-
taskRef:
74-
kind: Task
75-
name: ods-build-go-v0-6-0
76-
workspaces:
77-
- name: source
78-
workspace: shared-workspace
79-
- name: package-image
80-
taskRef:
81-
kind: Task
82-
name: ods-package-image-v0-6-0
83-
runAfter:
84-
- build-go
85-
workspaces:
86-
- name: source
87-
workspace: shared-workspace
88-
- name: deploy-helm
89-
taskRef:
90-
kind: Task
91-
name: ods-deploy-helm-v0-6-0
92-
runAfter:
93-
- package-image
94-
workspaces:
95-
- name: source
96-
workspace: shared-workspace
71+
- tasks:
72+
- name: build-go
73+
taskRef:
74+
kind: Task
75+
name: ods-build-go-v0-6-0
76+
workspaces:
77+
- name: source
78+
workspace: shared-workspace
79+
- name: package-image
80+
taskRef:
81+
kind: Task
82+
name: ods-package-image-v0-6-0
83+
runAfter:
84+
- build-go
85+
workspaces:
86+
- name: source
87+
workspace: shared-workspace
88+
- name: deploy-helm
89+
taskRef:
90+
kind: Task
91+
name: ods-deploy-helm-v0-6-0
92+
runAfter:
93+
- package-image
94+
workspaces:
95+
- name: source
96+
workspace: shared-workspace
9797
----
9898

9999
You can see that it defines three tasks, `build-go`, `package-image` and `deploy-helm`, which run sequentially due to the usage of `runAfter`.

0 commit comments

Comments
 (0)