Merge "typo and add link for jenkins Managed Files"
[releng/global-jjb.git] / jjb / lf-docker-jobs.yaml
1 ---
2 # This file contains job templates for Docker projects.
3
4 ##########
5 # Macros #
6 ##########
7
8 - builder:
9     name: lf-docker-get-container-tag
10     builders:
11       - inject:
12           properties-content: |
13             CONTAINER_TAG_METHOD={container-tag-method}
14             CONTAINER_TAG_YAML_DIR={container-tag-yaml-dir}
15             DOCKER_ROOT={docker-root}
16       - shell: !include-raw-escape:
17           - ../shell/docker-get-container-tag.sh
18       - inject:
19           # Import the container tag set by this build step
20           properties-file: 'env_docker_inject.txt'
21
22 - builder:
23     name: lf-docker-build
24     builders:
25       - inject:
26           properties-content: |
27             DOCKER_ARGS={docker-build-args}
28             DOCKER_NAME={docker-name}
29             DOCKER_ROOT={docker-root}
30             CONTAINER_PULL_REGISTRY={container-public-registry}
31             CONTAINER_PUSH_REGISTRY={container-push-registry}
32       - shell: !include-raw-escape:
33           - ../shell/docker-build.sh
34
35 - builder:
36     name: lf-docker-push
37     builders:
38       - inject:
39           properties-content: |
40               CONTAINER_PUSH_REGISTRY={container-push-registry}
41       - shell: !include-raw-escape:
42           - ../shell/docker-push.sh
43
44 ####################
45 # COMMON FUNCTIONS #
46 ####################
47
48 - lf_docker_common: &lf_docker_common
49     name: lf-docker-common
50
51     project-type: freestyle
52     node: '{build-node}'
53
54     ######################
55     # Default parameters #
56     ######################
57
58     branch: master
59     build-days-to-keep: 7
60     build-timeout: 60
61     submodule-disable: false
62     submodule-recursive: true
63     submodule-timeout: 10
64     pre_docker_build_script: '# pre docker build script goes here'
65     post_docker_build_script: '# post docker build script goes here'
66     disable-job: 'false'
67     docker-root: '$WORKSPACE'
68     docker-build-args: ''
69     git-url: '$GIT_URL/$PROJECT'
70     container-tag-method: 'latest'
71     # TODO: how to interpolate value of {docker-root} parameter?
72     container-tag-yaml-dir: ''
73
74     #####################
75     # Job Configuration #
76     #####################
77
78     disabled: '{disable-job}'
79
80     properties:
81       - lf-infra-properties:
82           build-days-to-keep: '{build-days-to-keep}'
83
84     parameters:
85       - lf-infra-parameters:
86           branch: '{branch}'
87           project: '{project}'
88           refspec: 'refs/heads/{branch}'
89           stream: '{stream}'
90
91     wrappers:
92       - lf-infra-wrappers:
93           build-timeout: '{build-timeout}'
94           jenkins-ssh-credential: '{jenkins-ssh-credential}'
95
96     publishers:
97       - lf-infra-publish
98
99 - docker_verify_common: &docker_verify_common
100     name: docker-verify-common
101
102     concurrent: true
103
104     scm:
105       - lf-infra-gerrit-scm:
106           jenkins-ssh-credential: '{jenkins-ssh-credential}'
107           git-url: '{git-url}'
108           refspec: '$GERRIT_REFSPEC'
109           branch: '$GERRIT_BRANCH'
110           submodule-disable: '{submodule-disable}'
111           submodule-recursive: '{submodule-recursive}'
112           submodule-timeout: '{submodule-timeout}'
113           choosing-strategy: gerrit
114
115     gerrit_verify_triggers:
116       - patchset-created-event:
117           exclude-drafts: true
118           exclude-trivial-rebase: false
119           exclude-no-code-change: false
120       - draft-published-event
121       - comment-added-contains-event:
122           comment-contains-value: '^Patch Set[ ]+[0-9]+:([ ]+|[\n]+)(recheck|reverify)$'
123
124     gerrit_trigger_file_paths:
125       - compare-type: REG_EXP
126         pattern: '.*'
127
128     # github_included_regions MUST match gerrit_trigger_file_paths
129     github_included_regions:
130       - '.*'
131
132     builders:
133       - lf-infra-pre-build
134       - lf-infra-docker-login:
135           global-settings-file: 'global-settings'
136           settings-file: '{mvn-settings}'
137       - shell: '{pre_docker_build_script}'
138       - lf-docker-get-container-tag:
139           container-tag-method: '{container-tag-method}'
140           container-tag-yaml-dir: '{container-tag-yaml-dir}'
141           docker-root: '{docker-root}'
142       - lf-docker-build:
143           docker-build-args: '{docker-build-args}'
144           docker-name: '{docker-name}'
145           docker-root: '{docker-root}'
146           container-public-registry: '{container-public-registry}'
147           container-push-registry: '{container-push-registry}'
148       - shell: '{post_docker_build_script}'
149       - lf-provide-maven-settings-cleanup
150
151 - docker_merge_common: &docker_merge_common
152     name: docker-merge-common
153     cron: ''
154
155     scm:
156       - lf-infra-gerrit-scm:
157           jenkins-ssh-credential: '{jenkins-ssh-credential}'
158           git-url: '{git-url}'
159           refspec: '$GERRIT_REFSPEC'
160           branch: '$GERRIT_BRANCH'
161           submodule-disable: '{submodule-disable}'
162           submodule-recursive: '{submodule-recursive}'
163           submodule-timeout: '{submodule-timeout}'
164           choosing-strategy: gerrit
165
166     gerrit_merge_triggers:
167       - change-merged-event
168       - comment-added-contains-event:
169           comment-contains-value: remerge$
170
171     gerrit_trigger_file_paths:
172       - compare-type: REG_EXP
173         pattern: '.*'
174
175     # github_included_regions MUST match gerrit_trigger_file_paths
176     github_included_regions:
177       - '.*'
178
179     builders:
180       - lf-infra-pre-build
181       - lf-infra-docker-login:
182           global-settings-file: 'global-settings'
183           settings-file: '{mvn-settings}'
184       - shell: '{pre_docker_build_script}'
185       - lf-docker-get-container-tag:
186           container-tag-method: '{container-tag-method}'
187           container-tag-yaml-dir: '{container-tag-yaml-dir}'
188           docker-root: '{docker-root}'
189       - lf-docker-build:
190           docker-build-args: '{docker-build-args}'
191           docker-name: '{docker-name}'
192           docker-root: '{docker-root}'
193           container-public-registry: '{container-public-registry}'
194           container-push-registry: '{container-push-registry}'
195       - shell: '{post_docker_build_script}'
196       # Provided all steps have already passed, push the docker image
197       - lf-docker-push:
198           container-push-registry: '{container-push-registry}'
199       - lf-provide-maven-settings-cleanup
200
201 #################
202 # Docker Verify #
203 #################
204
205 - job-template:
206     name: '{project-name}-docker-verify-{stream}'
207     id: gerrit-docker-verify
208     # Job template for Docker verify jobs
209     #
210     # The purpose of this job template is to run a docker build, and potentially
211     # test validation of the docker image
212
213     <<: *lf_docker_common
214     # yamllint disable-line rule:key-duplicates
215     <<: *docker_verify_common
216
217     triggers:
218       - gerrit:
219           server-name: '{gerrit-server-name}'
220           trigger-on: '{obj:gerrit_verify_triggers}'
221           projects:
222             - project-compare-type: ANT
223               project-pattern: '{project}'
224               branches:
225                 - branch-compare-type: ANT
226                   branch-pattern: '**/{branch}'
227               file-paths: '{obj:gerrit_trigger_file_paths}'
228
229 - job-template:
230     name: '{project-name}-docker-verify-{stream}'
231     id: github-docker-verify
232     # Job template for Docker verify jobs
233     #
234     # The purpose of this job template is to run a docker build, and potentially
235     # test validation of the docker image
236
237     <<: *lf_docker_common
238     # yamllint disable-line rule:key-duplicates
239     <<: *docker_verify_common
240
241     properties:
242       - lf-infra-properties:
243           build-days-to-keep: '{build-days-to-keep}'
244       - github:
245           url: '{github-url}/{github-org}/{project}'
246
247     scm:
248       - lf-infra-github-scm:
249           url: '{git-clone-url}{github-org}/{project}'
250           refspec: '+refs/pull/*:refs/remotes/origin/pr/*'
251           branch: '$sha1'
252           submodule-recursive: '{submodule-recursive}'
253           submodule-timeout: '{submodule-timeout}'
254           submodule-disable: '{submodule-disable}'
255           choosing-strategy: default
256           jenkins-ssh-credential: '{jenkins-ssh-credential}'
257
258     triggers:
259       - github-pull-request:
260           trigger-phrase: '^(recheck|reverify)$'
261           only-trigger-phrase: false
262           status-context: 'Docker Verify'
263           permit-all: true
264           github-hooks: true
265           white-list-target-branches:
266             - '{branch}'
267           included-regions: '{obj:github_included_regions}'
268
269 ################
270 # Docker Merge #
271 ################
272
273 - job-template:
274     name: '{project-name}-docker-merge-{stream}'
275     id: gerrit-docker-merge
276     # Job template for Docker merge jobs
277     #
278     # The purpose of this job template is to run a docker build, and potentially
279     # test validation of the docker image
280
281     <<: *lf_docker_common
282     # yamllint disable-line rule:key-duplicates
283     <<: *docker_merge_common
284
285     triggers:
286       - timed: '{obj:cron}'
287       - gerrit:
288           server-name: '{gerrit-server-name}'
289           trigger-on: '{obj:gerrit_merge_triggers}'
290           projects:
291             - project-compare-type: ANT
292               project-pattern: '{project}'
293               branches:
294                 - branch-compare-type: ANT
295                   branch-pattern: '**/{branch}'
296               file-paths: '{obj:gerrit_trigger_file_paths}'
297
298 - job-template:
299     name: '{project-name}-docker-merge-{stream}'
300     id: github-docker-merge
301     # Job template for Docker merge jobs
302     #
303     # The purpose of this job template is to run a docker build, and potentially
304     # test validation of the docker image
305
306     <<: *lf_docker_common
307     # yamllint disable-line rule:key-duplicates
308     <<: *docker_merge_common
309
310     properties:
311       - lf-infra-properties:
312           build-days-to-keep: '{build-days-to-keep}'
313       - github:
314           url: '{github-url}/{github-org}/{project}'
315
316     scm:
317       - lf-infra-github-scm:
318           url: '{git-clone-url}{github-org}/{project}'
319           refspec: ''
320           branch: 'refs/heads/{branch}'
321           submodule-recursive: '{submodule-recursive}'
322           submodule-timeout: '{submodule-timeout}'
323           submodule-disable: '{submodule-disable}'
324           choosing-strategy: default
325           jenkins-ssh-credential: '{jenkins-ssh-credential}'
326
327     triggers:
328       - timed: '{obj:cron}'
329       - github
330       - pollscm:
331           cron: ''
332       - github-pull-request:
333           trigger-phrase: '^remerge$'
334           only-trigger-phrase: true
335           status-context: 'Docker Merge'
336           permit-all: true
337           github-hooks: true
338           org-list:
339             - '{github-org}'
340           white-list: '{obj:github_pr_whitelist}'
341           admin-list: '{obj:github_pr_admin_list}'
342           white-list-target-branches:
343             - '{branch}'
344           included-regions: '{obj:github_included_regions}'