Add global docker jobs
[ci-management.git] / jjb / global-templates-docker.yaml
1 ---
2 ###########
3 # ANCHORS #
4 ###########
5 - docker_job_boiler_plate: &docker_job_boiler_plate
6     name: docker_job_boiler_plate
7
8     project-type: freestyle
9     node: '{build-node}'
10
11     ######################
12     # Default parameters #
13     ######################
14
15     branch: master
16     submodule-recursive: true
17
18     # default params for docker jobs
19     pre_build_script: ''
20     post_build_script: ''
21     docker_root: '$WORKSPACE'
22     docker_build_args: ''
23     docker_name: 'unnamed'
24     # Default to LF standard 'snapshots' docker registry
25     docker_registry: '$DOCKER_REGISTRY:10003'
26     docker_tag: 'latest'
27
28     #####################
29     # Job Configuration #
30     #####################
31
32     properties:
33       - lf-infra-properties:
34           build-days-to-keep: '{build-days-to-keep}'
35
36     parameters:
37       - lf-infra-parameters:
38           branch: '{branch}'
39           project: '{project}'
40           stream: '{stream}'
41           lftools-version: '{lftools-version}'
42
43     wrappers:
44       - lf-infra-wrappers:
45           build-timeout: '{build-timeout}'
46           jenkins-ssh-credential: '{jenkins-ssh-credential}'
47
48     publishers:
49       - lf-infra-publish
50
51 - docker_verify_boiler_plate: &docker_verify_boiler_plate
52     name: docker_verify_boiler_plate
53
54     concurrent: true
55
56     scm:
57       - gerrit-trigger-scm:
58           refspec: '$GERRIT_REFSPEC'
59           choosing-strategy: 'default'
60           submodule-recursive: '{submodule-recursive}'
61
62     triggers:
63       - gerrit-trigger-patch-submitted:
64           status-context: '{project}-Docker-Verify'
65           server: '{server-name}'
66           project: '{project}'
67           branch: '{branch}'
68
69 - docker_merge_boiler_plate: &docker_merge_boiler_plate
70     name: docker_merge_boiler_plate
71
72     scm:
73       - gerrit-trigger-scm:
74           refspec: '$GERRIT_REFSPEC'
75           choosing-strategy: 'default'
76           submodule-recursive: '{submodule-recursive}'
77
78     triggers:
79       - gerrit-trigger-patch-merged:
80           server: '{server-name}'
81           project: '{project}'
82           branch: '{branch}'
83           files: '**'
84       - pollscm:
85           cron: ''
86
87 #################
88 # JOB TEMPLATES #
89 #################
90 - job-template:
91     name: '{project-name}-{stream}-merge-docker'
92     # Job template for Docker merge jobs
93     #
94     # The purpose of this job template is to run a docker build, and potentially
95     # test validation of the docker image
96
97     <<: *docker_job_boiler_plate
98     # yamllint disable-line rule:key-duplicates
99     <<: *docker_merge_boiler_plate
100
101     builders:
102       - lf-infra-docker-login:
103           global-settings-file: 'global-settings'
104           settings-file: '{mvn-settings}'
105       - shell: '{pre_build_script}'
106       - inject:
107           # Docker registry is purposely not using an '_' so as to not conflict
108           # with the Jenkins global env var
109           properties-content: |
110             DOCKER_ARGS={docker_build_args}
111             DOCKER_NAME={docker_name}
112             DOCKER_ROOT={docker_root}
113             DOCKER_TAG={docker_tag}
114             DOCKERREGISTRY={docker_registry}
115       # Do the docker build
116       - shell: !include-raw: ../shell/docker-build.sh
117       - inject:
118           # Import the docker image information from the build step
119           properties-file: 'env_inject.txt'
120       # Execute any post build clean-up or testing
121       - shell: '{post_build_script}'
122       # Provided all steps have already passed, push the docker image
123       - shell: !include-raw: ../shell/docker-push.sh
124
125 - job-template:
126     name: '{project-name}-{stream}-verify-docker'
127     # Job template for Docker verify jobs
128     #
129     # The purpose of this job template is to run a docker build, and potentially
130     # test validation of the docker image
131
132     ######################
133     # Default parameters #
134     ######################
135
136     <<: *docker_job_boiler_plate
137     # yamllint disable-line rule:key-duplicates
138     <<: *docker_verify_boiler_plate
139
140     builders:
141       - lf-infra-docker-login:
142           global-settings-file: 'global-settings'
143           settings-file: '{mvn-settings}'
144       - shell: '{pre_build_script}'
145       - inject:
146           # Docker registry is purposely not using an '_' so as to not conflict
147           # with the Jenkins global env var
148           properties-content: |
149             DOCKER_ARGS={docker_build_args}
150             DOCKER_NAME={docker_name}
151             DOCKER_ROOT={docker_root}
152             DOCKER_TAG={docker_tag}
153             DOCKERREGISTRY={docker_registry}
154       # Do the docker build
155       - shell: !include-raw: ../shell/docker-build.sh
156       - inject:
157           # Import the docker image information from the build step
158           properties-file: 'env_inject.txt'
159       # Execute any post build clean-up or testing
160       - shell: '{post_build_script}'
161
162 - job-template:
163     name: '{project-name}-{stream}-release-version-docker-daily-no-sonar'
164     # Job template for Docker daily release jobs
165     #
166     # The purpose of this job template is to run "docker build and docker push"
167     # for projects using this template.
168     #
169     # Required Variables:
170     #     branch:    git branch (eg. stable/lithium or master)
171     <<: *docker_job_boiler_plate
172
173     docker_registry: '$DOCKER_REGISTRY:10004'
174
175     scm:
176       - lf-infra-gerrit-scm:
177           jenkins-ssh-credential: '{jenkins-ssh-credential}'
178           git-url: '$GIT_URL/$PROJECT'
179           refspec: '$GERRIT_REFSPEC'
180           branch: '$GERRIT_BRANCH'
181           submodule-recursive: true
182           choosing-strategy: default
183
184     builders:
185       - lf-infra-docker-login:
186           global-settings-file: 'global-settings'
187           settings-file: '{mvn-settings}'
188       - shell: '{pre_build_script}'
189       - inject:
190           # Docker registry is purposely not using an '_' so as to not conflict
191           # with the Jenkins global env var
192           properties-content: |
193             DOCKER_ARGS={docker_build_args}
194             DOCKER_NAME={docker_name}
195             DOCKER_ROOT={docker_root}
196             DOCKER_TAG={docker_tag}
197             DOCKERREGISTRY={docker_registry}
198
199       # Do the docker build
200       - shell: !include-raw: ../shell/snapshot-strip.sh
201       - shell: !include-raw: ../shell/docker-build.sh
202       - inject:
203           # Import the docker image information from the build step
204           properties-file: 'env_inject.txt'
205       # Execute any post build clean-up or testing
206       - shell: '{post_build_script}'
207       # Provided all steps have already passed, push the docker image
208       - shell: !include-raw: ../shell/docker-push.sh
209
210     triggers:
211       # 11 AM UTC
212       - timed: 'H 11 * * *'
213       - gerrit-trigger-release-manually:
214           server: '{server-name}'
215           project: '{project}'
216           branch: '{branch}'
217
218 - job-template:
219     name: '{project-name}-{subproject}-{stream}-merge-docker'
220     # Job template for Docker merge jobs
221     #
222     # The purpose of this job template is to run a docker build, and potentially
223     # test validation of the docker image
224
225     <<: *docker_job_boiler_plate
226     # yamllint disable-line rule:key-duplicates
227     <<: *docker_merge_boiler_plate
228
229     builders:
230       - lf-infra-docker-login:
231           global-settings-file: 'global-settings'
232           settings-file: '{mvn-settings}'
233       - shell: '{pre_build_script}'
234       - inject:
235           # Docker registry is purposely not using an '_' so as to not conflict
236           # with the Jenkins global env var
237           properties-content: |
238             DOCKER_ARGS={docker_build_args}
239             DOCKER_NAME={docker_name}
240             DOCKER_ROOT={docker_root}
241             DOCKER_TAG={docker_tag}
242             DOCKERREGISTRY={docker_registry}
243       # Do the docker build
244       - shell: !include-raw: ../shell/docker-build.sh
245       - inject:
246           # Import the docker image information from the build step
247           properties-file: 'env_inject.txt'
248       # Execute any post build clean-up or testing
249       - shell: '{post_build_script}'
250       # Provided all steps have already passed, push the docker image
251       - shell: !include-raw: ../shell/docker-push.sh
252
253 - job-template:
254     name: '{project-name}-{subproject}-{stream}-verify-docker'
255     # Job template for Docker verify jobs
256     #
257     # The purpose of this job template is to run a docker build, and potentially
258     # test validation of the docker image
259
260     ######################
261     # Default parameters #
262     ######################
263
264     <<: *docker_job_boiler_plate
265     # yamllint disable-line rule:key-duplicates
266     <<: *docker_verify_boiler_plate
267
268     builders:
269       - lf-infra-docker-login:
270           global-settings-file: 'global-settings'
271           settings-file: '{mvn-settings}'
272       - shell: '{pre_build_script}'
273       - inject:
274           # Docker registry is purposely not using an '_' so as to not conflict
275           # with the Jenkins global env var
276           properties-content: |
277             DOCKER_ARGS={docker_build_args}
278             DOCKER_NAME={docker_name}
279             DOCKER_ROOT={docker_root}
280             DOCKER_TAG={docker_tag}
281             DOCKERREGISTRY={docker_registry}
282       # Do the docker build
283       - shell: !include-raw: ../shell/docker-build.sh
284       - inject:
285           # Import the docker image information from the build step
286           properties-file: 'env_inject.txt'
287       # Execute any post build clean-up or testing
288       - shell: '{post_build_script}'
289
290 - job-template:
291     name: '{project-name}-{subproject}-{stream}-release-version-docker-daily-no-sonar'
292     # Job template for Docker daily release jobs
293     #
294     # The purpose of this job template is to run "docker build and docker push"
295     # for projects using this template.
296     #
297     # Required Variables:
298     #     branch:    git branch (eg. stable/lithium or master)
299     <<: *docker_job_boiler_plate
300
301     docker_registry: '$DOCKER_REGISTRY:10004'
302
303     scm:
304       - lf-infra-gerrit-scm:
305           jenkins-ssh-credential: '{jenkins-ssh-credential}'
306           git-url: '$GIT_URL/$PROJECT'
307           refspec: '$GERRIT_REFSPEC'
308           branch: '$GERRIT_BRANCH'
309           submodule-recursive: true
310           choosing-strategy: default
311
312     builders:
313       - lf-infra-docker-login:
314           global-settings-file: 'global-settings'
315           settings-file: '{mvn-settings}'
316       - shell: '{pre_build_script}'
317       - inject:
318           # Docker registry is purposely not using an '_' so as to not conflict
319           # with the Jenkins global env var
320           properties-content: |
321             DOCKER_ARGS={docker_build_args}
322             DOCKER_NAME={docker_name}
323             DOCKER_ROOT={docker_root}
324             DOCKER_TAG={docker_tag}
325             DOCKERREGISTRY={docker_registry}
326
327       # Do the docker build
328       - shell: !include-raw: ../shell/snapshot-strip.sh
329       - shell: !include-raw: ../shell/docker-build.sh
330       - inject:
331           # Import the docker image information from the build step
332           properties-file: 'env_inject.txt'
333       # Execute any post build clean-up or testing
334       - shell: '{post_build_script}'
335       # Provided all steps have already passed, push the docker image
336       - shell: !include-raw: ../shell/docker-push.sh
337
338     triggers:
339       # 11 AM UTC
340       - timed: 'H 11 * * *'
341       - gerrit-trigger-release-manually:
342           server: '{server-name}'
343           project: '{project}'
344           branch: '{branch}'