Add template to build release docker image
[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           files: '{files}'
69
70 - docker_merge_boiler_plate: &docker_merge_boiler_plate
71     name: docker_merge_boiler_plate
72
73     scm:
74       - gerrit-trigger-scm:
75           refspec: '$GERRIT_REFSPEC'
76           choosing-strategy: 'default'
77           submodule-recursive: '{submodule-recursive}'
78
79     triggers:
80       - gerrit-trigger-patch-merged:
81           server: '{server-name}'
82           project: '{project}'
83           branch: '{branch}'
84           files: '{files}'
85       - pollscm:
86           cron: ''
87
88 #################
89 # JOB TEMPLATES #
90 #################
91 - job-template:
92     name: '{project-name}-{stream}-merge-docker'
93     # Job template for Docker merge jobs
94     #
95     # The purpose of this job template is to run a docker build, and potentially
96     # test validation of the docker image
97
98     <<: *docker_job_boiler_plate
99     # yamllint disable-line rule:key-duplicates
100     <<: *docker_merge_boiler_plate
101
102     builders:
103       - lf-infra-docker-login:
104           global-settings-file: 'global-settings'
105           settings-file: '{mvn-settings}'
106       - shell: '{pre_build_script}'
107       - inject:
108           # Docker registry is purposely not using an '_' so as to not conflict
109           # with the Jenkins global env var
110           properties-content: |
111             DOCKER_ARGS={docker_build_args}
112             DOCKER_NAME={docker_name}
113             DOCKER_ROOT={docker_root}
114             DOCKER_TAG={docker_tag}
115             BUILD_MODE=SNAPSHOT
116             DOCKERREGISTRY={docker_registry}
117       # Do the docker build
118       - shell: !include-raw: ../shell/docker-build.sh
119       - inject:
120           # Import the docker image information from the build step
121           properties-file: 'env_inject.txt'
122       # Execute any post build clean-up or testing
123       - shell: '{post_build_script}'
124       # Provided all steps have already passed, push the docker image
125       - shell: !include-raw: ../shell/docker-push.sh
126
127 - job-template:
128     name: '{project-name}-{stream}-verify-docker'
129     # Job template for Docker verify jobs
130     #
131     # The purpose of this job template is to run a docker build, and potentially
132     # test validation of the docker image
133
134     ######################
135     # Default parameters #
136     ######################
137
138     <<: *docker_job_boiler_plate
139     # yamllint disable-line rule:key-duplicates
140     <<: *docker_verify_boiler_plate
141
142     builders:
143       - lf-infra-docker-login:
144           global-settings-file: 'global-settings'
145           settings-file: '{mvn-settings}'
146       - shell: '{pre_build_script}'
147       - inject:
148           # Docker registry is purposely not using an '_' so as to not conflict
149           # with the Jenkins global env var
150           properties-content: |
151             DOCKER_ARGS={docker_build_args}
152             DOCKER_NAME={docker_name}
153             DOCKER_ROOT={docker_root}
154             DOCKER_TAG={docker_tag}
155             BUILD_MODE=SNAPSHOT
156             DOCKERREGISTRY={docker_registry}
157       # Do the docker build
158       - shell: !include-raw: ../shell/docker-build.sh
159       - inject:
160           # Import the docker image information from the build step
161           properties-file: 'env_inject.txt'
162       # Execute any post build clean-up or testing
163       - shell: '{post_build_script}'
164
165 - job-template:
166     name: '{project-name}-{stream}-release-version-docker-daily-no-sonar'
167     # Job template for Docker daily release jobs
168     #
169     # The purpose of this job template is to run "docker build and docker push"
170     # for projects using this template.
171     #
172     # Required Variables:
173     #     branch:    git branch (eg. stable/lithium or master)
174     <<: *docker_job_boiler_plate
175
176     docker_registry: '$DOCKER_REGISTRY:10003'
177
178     scm:
179       - lf-infra-gerrit-scm:
180           jenkins-ssh-credential: '{jenkins-ssh-credential}'
181           git-url: '$GIT_URL/$PROJECT'
182           refspec: '$GERRIT_REFSPEC'
183           branch: '$GERRIT_BRANCH'
184           submodule-recursive: true
185           choosing-strategy: default
186
187     builders:
188       - lf-infra-docker-login:
189           global-settings-file: 'global-settings'
190           settings-file: '{mvn-settings}'
191       - shell: '{pre_build_script}'
192       - inject:
193           # Docker registry is purposely not using an '_' so as to not conflict
194           # with the Jenkins global env var
195           properties-content: |
196             DOCKER_ARGS={docker_build_args}
197             DOCKER_NAME={docker_name}
198             DOCKER_ROOT={docker_root}
199             DOCKER_TAG={docker_tag}
200             DOCKERREGISTRY={docker_registry}
201             BUILD_MODE=STAGING
202
203       # Do the docker build
204       - shell: !include-raw: ../shell/snapshot-strip.sh
205       - shell: !include-raw: ../shell/docker-build.sh
206       - inject:
207           # Import the docker image information from the build step
208           properties-file: 'env_inject.txt'
209       # Execute any post build clean-up or testing
210       - shell: '{post_build_script}'
211       # Provided all steps have already passed, push the docker image
212       - shell: !include-raw: ../shell/docker-push.sh
213
214     triggers:
215       # 11 AM UTC
216       - timed: 'H 11 * * *'
217       - gerrit-trigger-release-manually:
218           server: '{server-name}'
219           project: '{project}'
220           branch: '{branch}'
221
222 - job-template:
223     name: '{project-name}-{subproject}-{stream}-merge-docker'
224     # Job template for Docker merge jobs
225     #
226     # The purpose of this job template is to run a docker build, and potentially
227     # test validation of the docker image
228
229     <<: *docker_job_boiler_plate
230     # yamllint disable-line rule:key-duplicates
231     <<: *docker_merge_boiler_plate
232
233     builders:
234       - lf-infra-docker-login:
235           global-settings-file: 'global-settings'
236           settings-file: '{mvn-settings}'
237       - shell: '{pre_build_script}'
238       - inject:
239           # Docker registry is purposely not using an '_' so as to not conflict
240           # with the Jenkins global env var
241           properties-content: |
242             DOCKER_ARGS={docker_build_args}
243             DOCKER_NAME={docker_name}
244             DOCKER_ROOT={docker_root}
245             DOCKER_TAG={docker_tag}
246             DOCKERREGISTRY={docker_registry}
247             BUILD_MODE=SNAPSHOT
248       # Do the docker build
249       - shell: !include-raw: ../shell/docker-build.sh
250       - inject:
251           # Import the docker image information from the build step
252           properties-file: 'env_inject.txt'
253       # Execute any post build clean-up or testing
254       - shell: '{post_build_script}'
255       # Provided all steps have already passed, push the docker image
256       - shell: !include-raw: ../shell/docker-push.sh
257
258 - job-template:
259     name: '{project-name}-{subproject}-{stream}-verify-docker'
260     # Job template for Docker verify jobs
261     #
262     # The purpose of this job template is to run a docker build, and potentially
263     # test validation of the docker image
264
265     ######################
266     # Default parameters #
267     ######################
268
269     <<: *docker_job_boiler_plate
270     # yamllint disable-line rule:key-duplicates
271     <<: *docker_verify_boiler_plate
272
273     builders:
274       - lf-infra-docker-login:
275           global-settings-file: 'global-settings'
276           settings-file: '{mvn-settings}'
277       - shell: '{pre_build_script}'
278       - inject:
279           # Docker registry is purposely not using an '_' so as to not conflict
280           # with the Jenkins global env var
281           properties-content: |
282             DOCKER_ARGS={docker_build_args}
283             DOCKER_NAME={docker_name}
284             DOCKER_ROOT={docker_root}
285             DOCKER_TAG={docker_tag}
286             DOCKERREGISTRY={docker_registry}
287             BUILD_MODE=SNAPSHOT
288       # Do the docker build
289       - shell: !include-raw: ../shell/docker-build.sh
290       - inject:
291           # Import the docker image information from the build step
292           properties-file: 'env_inject.txt'
293       # Execute any post build clean-up or testing
294       - shell: '{post_build_script}'
295
296 - job-template:
297     name: '{project-name}-{subproject}-{stream}-release-version-docker-daily-no-sonar'
298     # Job template for Docker daily release jobs
299     #
300     # The purpose of this job template is to run "docker build and docker push"
301     # for projects using this template.
302     #
303     # Required Variables:
304     #     branch:    git branch (eg. stable/lithium or master)
305     <<: *docker_job_boiler_plate
306
307     docker_registry: '$DOCKER_REGISTRY:10003'
308
309     scm:
310       - lf-infra-gerrit-scm:
311           jenkins-ssh-credential: '{jenkins-ssh-credential}'
312           git-url: '$GIT_URL/$PROJECT'
313           refspec: '$GERRIT_REFSPEC'
314           branch: '$GERRIT_BRANCH'
315           submodule-recursive: true
316           choosing-strategy: default
317
318     builders:
319       - lf-infra-docker-login:
320           global-settings-file: 'global-settings'
321           settings-file: '{mvn-settings}'
322       - shell: '{pre_build_script}'
323       - inject:
324           # Docker registry is purposely not using an '_' so as to not conflict
325           # with the Jenkins global env var
326           properties-content: |
327             DOCKER_ARGS={docker_build_args}
328             DOCKER_NAME={docker_name}
329             DOCKER_ROOT={docker_root}
330             DOCKER_TAG={docker_tag}
331             DOCKERREGISTRY={docker_registry}
332             BUILD_MODE=STAGING
333
334       # Do the docker build
335       - shell: !include-raw: ../shell/snapshot-strip.sh
336       - shell: !include-raw: ../shell/docker-build.sh
337       - inject:
338           # Import the docker image information from the build step
339           properties-file: 'env_inject.txt'
340       # Execute any post build clean-up or testing
341       - shell: '{post_build_script}'
342       # Provided all steps have already passed, push the docker image
343       - shell: !include-raw: ../shell/docker-push.sh
344
345     triggers:
346       # 11 AM UTC
347       - timed: 'H 11 * * *'
348       - gerrit-trigger-release-manually:
349           server: '{server-name}'
350           project: '{project}'
351           branch: '{branch}'
352
353 - job-template:
354     name: '{project-name}-{subproject}-{stream}-release-version-docker-no-sonar'
355     # Job template for Docker final release job
356     #
357     # The purpose of this job template is to run "docker build and docker push"
358     # for projects using this template.
359     #
360     # Required Variables:
361     #     branch:    git branch (eg. stable/lithium or master)
362     <<: *docker_job_boiler_plate
363
364     docker_registry: '$DOCKER_REGISTRY:10003'
365
366     scm:
367       - lf-infra-gerrit-scm:
368           jenkins-ssh-credential: '{jenkins-ssh-credential}'
369           git-url: '$GIT_URL/$PROJECT'
370           refspec: '$GERRIT_REFSPEC'
371           branch: '$GERRIT_BRANCH'
372           submodule-recursive: true
373           choosing-strategy: default
374
375     builders:
376       - lf-infra-docker-login:
377           global-settings-file: 'global-settings'
378           settings-file: '{mvn-settings}'
379       - shell: '{pre_build_script}'
380       - inject:
381           # Docker registry is purposely not using an '_' so as to not conflict
382           # with the Jenkins global env var
383           properties-content: |
384             DOCKER_ARGS={docker_build_args}
385             DOCKER_NAME={docker_name}
386             DOCKER_ROOT={docker_root}
387             DOCKER_TAG={docker_tag}
388             DOCKERREGISTRY={docker_registry}
389             BUILD_MODE=STAGING
390
391       # Do the docker build
392       - shell: !include-raw: ../shell/snapshot-strip.sh
393       - shell: !include-raw: ../shell/docker-build.sh
394       - inject:
395           # Import the docker image information from the build step
396           properties-file: 'env_inject.txt'
397       # Execute any post build clean-up or testing
398       - shell: '{post_build_script}'
399       # Provided all steps have already passed, push the docker image
400       - shell: !include-raw: ../shell/docker-push.sh
401