Skip to content

Commit 3a8d173

Browse files
committed
Reduce repetition in CI pipeline.yml
Use YAML anchors and aliases to reduce the amount of repetition in our CI pipeline YAML. Closes gh-21716
1 parent ce13235 commit 3a8d173

File tree

1 file changed

+68
-77
lines changed

1 file changed

+68
-77
lines changed

ci/pipeline.yml

Lines changed: 68 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,49 @@
1+
anchors:
2+
git-repo-resource-source: &git-repo-resource-source
3+
uri: ((github-repo))
4+
username: ((github-username))
5+
password: ((github-password))
6+
branch: ((branch))
7+
docker-resource-source: &docker-resource-source
8+
username: ((docker-hub-username))
9+
password: ((docker-hub-password))
10+
tag: ((branch))
11+
build-project-task-params: &build-project-task-params
12+
privileged: true
13+
timeout: ((task-timeout))
14+
file: git-repo/ci/tasks/build-project.yml
15+
github-task-params: &github-task-params
16+
GITHUB_REPO: spring-boot
17+
GITHUB_ORGANIZATION: spring-projects
18+
GITHUB_PASSWORD: ((github-password))
19+
GITHUB_USERNAME: ((github-username))
20+
MILESTONE: ((milestone))
21+
bintray-task-params: &bintray-task-params
22+
BINTRAY_SUBJECT: ((bintray-subject))
23+
BINTRAY_REPO: ((bintray-repo))
24+
BINTRAY_USERNAME: ((bintray-username))
25+
BINTRAY_API_KEY: ((bintray-api-key))
26+
sontatype-task-params: &sonatype-task-params
27+
SONATYPE_USER_TOKEN: ((sonatype-user-token))
28+
SONATYPE_PASSWORD_TOKEN: ((sonatype-user-token-password))
29+
artifactory-task-params: &artifactory-task-params
30+
ARTIFACTORY_SERVER: ((artifactory-server))
31+
ARTIFACTORY_USERNAME: ((artifactory-username))
32+
ARTIFACTORY_PASSWORD: ((artifactory-password))
33+
artifactory-repo-put-params: &artifactory-repo-put-params
34+
repo: libs-snapshot-local
35+
folder: distribution-repository
36+
build_uri: "https://ci.spring.io/teams/${BUILD_TEAM_NAME}/pipelines/${BUILD_PIPELINE_NAME}/jobs/${BUILD_JOB_NAME}/builds/${BUILD_NAME}"
37+
build_number: "${BUILD_PIPELINE_NAME}-${BUILD_JOB_NAME}-${BUILD_NAME}"
38+
disable_checksum_uploads: true
39+
exclude:
40+
- "**/*.effective-pom"
41+
artifact_set:
42+
- include:
43+
- "/**/spring-boot-docs-*.zip"
44+
properties:
45+
"zip.type": "docs"
46+
"zip.deployed": "false"
147
resource_types:
248
- name: artifactory-resource
349
type: docker-image
@@ -23,18 +69,12 @@ resources:
2369
type: git
2470
icon: github-circle
2571
source:
26-
uri: ((github-repo))
27-
username: ((github-username))
28-
password: ((github-password))
29-
branch: ((branch))
72+
<<: *git-repo-resource-source
3073
- name: git-repo-windows
3174
type: git
3275
icon: github-circle
33-
source:
34-
uri: ((github-repo))
35-
username: ((github-username))
36-
password: ((github-password))
37-
branch: ((branch))
76+
source:
77+
<<: *git-repo-resource-source
3878
git_config:
3979
- name: core.autocrlf
4080
value: true
@@ -74,18 +114,14 @@ resources:
74114
type: docker-image
75115
icon: docker
76116
source:
117+
<<: *docker-resource-source
77118
repository: ((docker-hub-organization))/spring-boot-ci-image
78-
username: ((docker-hub-username))
79-
password: ((docker-hub-password))
80-
tag: ((branch))
81119
- name: spring-boot-jdk11-ci-image
82120
type: docker-image
83121
icon: docker
84122
source:
123+
<<: *docker-resource-source
85124
repository: ((docker-hub-organization))/spring-boot-jdk11-ci-image
86-
username: ((docker-hub-username))
87-
password: ((docker-hub-password))
88-
tag: ((branch))
89125
- name: artifactory-repo
90126
type: artifactory-resource
91127
icon: package-variant
@@ -149,22 +185,14 @@ jobs:
149185
- task: detect-jdk8-update
150186
file: git-repo/ci/tasks/detect-jdk-updates.yml
151187
params:
152-
GITHUB_REPO: spring-boot
153-
GITHUB_ORGANIZATION: spring-projects
154-
GITHUB_PASSWORD: ((github-password))
155-
GITHUB_USERNAME: ((github-username))
188+
<<: *github-task-params
156189
JDK_VERSION: java8
157-
MILESTONE: ((milestone))
158190
image: spring-boot-ci-image
159191
- task: detect-jdk11-update
160192
file: git-repo/ci/tasks/detect-jdk-updates.yml
161193
params:
162-
GITHUB_REPO: spring-boot
163-
GITHUB_ORGANIZATION: spring-projects
164-
GITHUB_PASSWORD: ((github-password))
165-
GITHUB_USERNAME: ((github-username))
194+
<<: *github-task-params
166195
JDK_VERSION: java11
167-
MILESTONE: ((milestone))
168196
image: spring-boot-ci-image
169197
- name: detect-ubuntu-image-updates
170198
plan:
@@ -176,11 +204,7 @@ jobs:
176204
- task: detect-ubuntu-image-updates
177205
file: git-repo/ci/tasks/detect-ubuntu-image-updates.yml
178206
params:
179-
GITHUB_REPO: spring-boot
180-
GITHUB_ORGANIZATION: spring-projects
181-
GITHUB_PASSWORD: ((github-password))
182-
GITHUB_USERNAME: ((github-username))
183-
MILESTONE: ((milestone))
207+
<<: *github-task-params
184208
image: spring-boot-ci-image
185209
- name: detect-docker-updates
186210
plan:
@@ -192,11 +216,7 @@ jobs:
192216
- task: detect-docker-updates
193217
file: git-repo/ci/tasks/detect-docker-updates.yml
194218
params:
195-
GITHUB_REPO: spring-boot
196-
GITHUB_ORGANIZATION: spring-projects
197-
GITHUB_PASSWORD: ((github-password))
198-
GITHUB_USERNAME: ((github-username))
199-
MILESTONE: ((milestone))
219+
<<: *github-task-params
200220
image: spring-boot-ci-image
201221
- name: build
202222
serial: true
@@ -209,10 +229,8 @@ jobs:
209229
params: { state: "pending", commit: "git-repo" }
210230
- do:
211231
- task: build-project
212-
privileged: true
213-
timeout: ((task-timeout))
232+
<<: *build-project-task-params
214233
image: spring-boot-ci-image
215-
file: git-repo/ci/tasks/build-project.yml
216234
- in_parallel:
217235
- task: build-samples
218236
timeout: ((task-timeout))
@@ -239,20 +257,8 @@ jobs:
239257
- put: repo-status-build
240258
params: { state: "success", commit: "git-repo" }
241259
- put: artifactory-repo
242-
params: &artifactory-params
243-
repo: libs-snapshot-local
244-
folder: distribution-repository
245-
build_uri: "https://ci.spring.io/teams/${BUILD_TEAM_NAME}/pipelines/${BUILD_PIPELINE_NAME}/jobs/${BUILD_JOB_NAME}/builds/${BUILD_NAME}"
246-
build_number: "${BUILD_PIPELINE_NAME}-${BUILD_JOB_NAME}-${BUILD_NAME}"
247-
disable_checksum_uploads: true
248-
exclude:
249-
- "**/*.effective-pom"
250-
artifact_set:
251-
- include:
252-
- "/**/spring-boot-docs-*.zip"
253-
properties:
254-
"zip.type": "docs"
255-
"zip.deployed": "false"
260+
params:
261+
<<: *artifactory-repo-put-params
256262
on_failure:
257263
do:
258264
- put: slack-alert
@@ -319,10 +325,8 @@ jobs:
319325
params: { state: "pending", commit: "git-repo" }
320326
- do:
321327
- task: build-project
322-
privileged: true
323-
timeout: ((task-timeout))
328+
<<: *build-project-task-params
324329
image: spring-boot-jdk11-ci-image
325-
file: git-repo/ci/tasks/build-project.yml
326330
- in_parallel:
327331
- task: build-samples
328332
timeout: ((task-timeout))
@@ -395,7 +399,7 @@ jobs:
395399
RELEASE_TYPE: M
396400
- put: artifactory-repo
397401
params:
398-
<<: *artifactory-params
402+
<<: *artifactory-repo-put-params
399403
repo: libs-staging-local
400404
- put: git-repo
401405
params:
@@ -413,7 +417,7 @@ jobs:
413417
RELEASE_TYPE: RC
414418
- put: artifactory-repo
415419
params:
416-
<<: *artifactory-params
420+
<<: *artifactory-repo-put-params
417421
repo: libs-staging-local
418422
- put: git-repo
419423
params:
@@ -431,7 +435,7 @@ jobs:
431435
RELEASE_TYPE: RELEASE
432436
- put: artifactory-repo
433437
params:
434-
<<: *artifactory-params
438+
<<: *artifactory-repo-put-params
435439
repo: libs-staging-local
436440
- put: git-repo
437441
params:
@@ -453,9 +457,7 @@ jobs:
453457
file: git-repo/ci/tasks/promote.yml
454458
params:
455459
RELEASE_TYPE: M
456-
ARTIFACTORY_SERVER: ((artifactory-server))
457-
ARTIFACTORY_USERNAME: ((artifactory-username))
458-
ARTIFACTORY_PASSWORD: ((artifactory-password))
460+
<<: *artifactory-task-params
459461
- task: generate-release-notes
460462
file: git-repo/ci/tasks/generate-release-notes.yml
461463
params:
@@ -484,9 +486,7 @@ jobs:
484486
file: git-repo/ci/tasks/promote.yml
485487
params:
486488
RELEASE_TYPE: RC
487-
ARTIFACTORY_SERVER: ((artifactory-server))
488-
ARTIFACTORY_USERNAME: ((artifactory-username))
489-
ARTIFACTORY_PASSWORD: ((artifactory-password))
489+
<<: *artifactory-task-params
490490
- task: generate-release-notes
491491
file: git-repo/ci/tasks/generate-release-notes.yml
492492
params:
@@ -515,13 +515,8 @@ jobs:
515515
file: git-repo/ci/tasks/promote.yml
516516
params:
517517
RELEASE_TYPE: RELEASE
518-
ARTIFACTORY_SERVER: ((artifactory-server))
519-
ARTIFACTORY_USERNAME: ((artifactory-username))
520-
ARTIFACTORY_PASSWORD: ((artifactory-password))
521-
BINTRAY_SUBJECT: ((bintray-subject))
522-
BINTRAY_REPO: ((bintray-repo))
523-
BINTRAY_USERNAME: ((bintray-username))
524-
BINTRAY_API_KEY: ((bintray-api-key))
518+
<<: *artifactory-task-params
519+
<<: *bintray-task-params
525520
- name: sync-to-maven-central
526521
serial: true
527522
plan:
@@ -537,12 +532,8 @@ jobs:
537532
image: spring-boot-ci-image
538533
file: git-repo/ci/tasks/sync-to-maven-central.yml
539534
params:
540-
BINTRAY_USERNAME: ((bintray-username))
541-
BINTRAY_API_KEY: ((bintray-api-key))
542-
SONATYPE_USER_TOKEN: ((sonatype-user-token))
543-
SONATYPE_PASSWORD_TOKEN: ((sonatype-user-token-password))
544-
BINTRAY_SUBJECT: ((bintray-subject))
545-
BINTRAY_REPO: ((bintray-repo))
535+
<<: *bintray-task-params
536+
<<: *sonatype-task-params
546537
- task: generate-release-notes
547538
file: git-repo/ci/tasks/generate-release-notes.yml
548539
params:

0 commit comments

Comments
 (0)