Add generic packer templates
[releng/global-jjb.git] / jjb / lf-ci-jobs.yaml
1 ---
2 - job-group:
3     name: '{project-name}-ci-jobs'
4
5     # This job group contains all the recommended jobs that should be deployed
6     # for any project ci.
7
8     jjb-version: 1.6.2
9
10     jobs:
11       - gerrit-jjb-merge
12       - gerrit-jjb-verify
13
14 - job-group:
15     name: '{project-name}-github-ci-jobs'
16
17     # This job group contains all the recommended jobs that should be deployed
18     # for any project ci that is using github.
19
20     jjb-version: 1.6.2
21
22     jobs:
23       - github-jjb-merge
24       - github-jjb-verify
25
26
27 - job-group:
28     name: '{project-name}-packer-jobs'
29
30     # This job group contains all the recommended jobs that should be deployed
31     # for any project ci that is using packer.
32
33     packer-version: 1.0.2
34
35     jobs:
36       - gerrit-packer-merge
37       - gerrit-packer-verify
38
39
40 - job-group:
41     name: '{project-name}-github-packer-jobs'
42
43     # This job group contains all the recommended jobs that should be deployed
44     # for any project ci that is using packer.
45
46     packer-version: 1.0.2
47
48     jobs:
49       - github-packer-merge
50       - github-packer-verify
51
52
53 ####################
54 # Anchors & Macros #
55 ####################
56
57 - builder:
58     name: lf-infra-jjbini
59     builders:
60       - config-file-provider:
61           files:
62             - file-id: jjbini
63               target: '$HOME/.config/jenkins_jobs/jenkins_jobs.ini'
64
65 - lf_jjb_file_paths: &lf_jjb_file_paths
66     name: lf-jjb-file-paths
67     file-paths:
68       - compare-type: ANT
69         pattern: '**/*.sh'
70       - compare-type: ANT
71         pattern: '**/*.yaml'
72
73 - lf_packer_file_paths: &lf_packer_file_paths
74     name: lf-packer-file-paths
75     file-paths:
76       # Common files for all projects
77       - compare-type: ANT
78         pattern: 'packer/vars/{platforms}.json'
79       - compare-type: ANT
80         pattern: 'packer/templates/{templates}.json'
81       - compare-type: ANT
82         pattern: 'packer/provision/{templates}.sh'
83       - compare-type: ANT
84         pattern: 'packer/provision/lib/**'
85
86 - lf_jjb_merge_builders: &lf_jjb_merge_builders
87     name: lf-jjb-merge-builders
88     builders:
89       - lf-infra-jjbini
90       - shell: !include-raw-escape:
91           - ../shell/jjb-install.sh
92           - ../shell/jjb-merge-job.sh
93
94 - lf_jjb_verify_builders: &lf_jjb_verify_builders
95     name: lf-jjb-verfy-builders
96     builders:
97       - lf-infra-jjbini
98       - shell: !include-raw-escape:
99           - ../shell/git-validate-jira-urls.sh
100           - ../shell/jjb-install.sh
101           - ../shell/jjb-verify-job.sh
102           - ../shell/jjb-check-unicode.sh
103       - lf-infra-gpg-verify-git-signature
104
105 - lf_packer: &lf_packer_common
106     name: lf-packer-common
107     # Adds wrappers and parameters sections common to packer jobs.
108     wrappers:
109       - lf-infra-wrappers:
110           build-timeout: 60
111           jenkins-ssh-credential: '{jenkins-ssh-credential}'
112
113     parameters:
114       - lf-infra-parameters:
115           project: '{project}'
116           stream: '{stream}'
117           branch: '{branch}'
118       - lf-infra-packer-parameters:
119           packer-version: '{packer-version}'
120
121 - lf_packer_merge_builders: &lf_packer_merge_builders
122     name: lf-packer-merge-builders
123     # Adds builders section common to merge packer jobs.
124     builders:
125       - lf-infra-packer-validate:
126           os-cloud-file-id: '{os-cloud-file-id}'
127           packer-version: '{packer-version}'
128       - lf-infra-packer-build:
129           platform: '{platforms}'
130           template: '{templates}'
131           os-cloud-file-id: '{os-cloud-file-id}'
132           packer-version: '{packer-version}'
133
134 - lf_packer_verify_builders: &lf_packer_verify_builders
135     # Adds builders section common to verify packer jobs.
136     name: lf-packer-verify-builders
137     builders:
138       - lf-infra-packer-validate:
139           os-cloud-file-id: '{os-cloud-file-id}'
140           packer-version: '{packer-version}'
141
142 - parameter:
143     name: lf-infra-jjb-parameters
144     parameters:
145       - string:
146           name: JJB_VERSION
147           default: '{jjb-version}'
148           description: Jenkins Job Builder version to download and install.
149
150 - parameter:
151     name: lf-infra-packer-parameters
152     parameters:
153       - string:
154           name: PACKER_VERSION
155           default: '{packer-version}'
156           description: Packer version to download and install.
157
158
159 #################
160 # Job Templates #
161 #################
162
163 # JJB verify and merge jobs are the same except for their scm, trigger, and
164 # builders definition. This anchor is the common template
165 - lf_jjb_verify_merge: &lf_jjb_verify_merge
166     name: lf-jjb-verify-merge
167     project-type: freestyle
168
169     node: '{build-node}'
170
171     ######################
172     # Default parameters #
173     ######################
174
175     stream: master
176     branch: master
177     submodule-recursive: true
178
179     #####################
180     # Job Configuration #
181     #####################
182
183     properties:
184       - lf-infra-properties:
185           project: '{project}'
186           build-days-to-keep: 7
187
188     parameters:
189       - lf-infra-parameters:
190           project: '{project}'
191           stream: '{stream}'
192           branch: '{branch}'
193       - lf-infra-jjb-parameters:
194           jjb-version: '{jjb-version}'
195
196     wrappers:
197       - lf-infra-wrappers:
198           build-timeout: 10
199           jenkins-ssh-credential: '{jenkins-ssh-credential}'
200
201     publishers:
202       - lf-infra-publish
203
204 - job-template:
205     name: '{project-name}-jjb-merge'
206     id: gerrit-jjb-merge
207     <<: *lf_jjb_verify_merge
208     # yamllint disable-line rule:key-duplicates
209     <<: *lf_jjb_merge_builders
210
211     ######################
212     # Default parameters #
213     ######################
214
215     git-url: '$GIT_URL/$GERRIT_PROJECT'
216
217     #####################
218     # Job Configuration #
219     #####################
220
221     scm:
222       - lf-infra-gerrit-scm:
223           git-url: '{git-url}'
224           refspec: ''
225           branch: '{branch}'
226           submodule-recursive: '{submodule-recursive}'
227           choosing-strategy: default
228           jenkins-ssh-credential: '{jenkins-ssh-credential}'
229
230     triggers:
231       - gerrit:
232           server-name: '{gerrit-server-name}'
233           trigger-on:
234             - change-merged-event
235             - comment-added-contains-event:
236                 comment-contains-value: remerge$
237           projects:
238             - project-compare-type: ANT
239               project-pattern: '{project}'
240               branches:
241                 - branch-compare-type: ANT
242                   branch-pattern: '**/{branch}'
243               <<: *lf_jjb_file_paths
244
245 - job-template:
246     name: '{project-name}-jjb-verify'
247     id: gerrit-jjb-verify
248     concurrent: true
249     <<: *lf_jjb_verify_merge
250     # yamllint disable-line rule:key-duplicates
251     <<: *lf_jjb_verify_builders
252
253     ######################
254     # Default parameters #
255     ######################
256
257     git-url: '$GIT_URL/$GERRIT_PROJECT'
258
259     #####################
260     # Job Configuration #
261     #####################
262
263     scm:
264       - lf-infra-gerrit-scm:
265           git-url: '{git-url}'
266           refspec: '$GERRIT_REFSPEC'
267           branch: '$GERRIT_BRANCH'
268           submodule-recursive: '{submodule-recursive}'
269           choosing-strategy: gerrit
270           jenkins-ssh-credential: '{jenkins-ssh-credential}'
271
272     triggers:
273       - gerrit:
274           server-name: '{gerrit-server-name}'
275           trigger-on:
276             - patchset-created-event:
277                 exclude-drafts: false
278                 exclude-trivial-rebase: false
279                 exclude-no-code-change: false
280             - draft-published-event
281             - comment-added-contains-event:
282                 comment-contains-value: recheck$
283           projects:
284             - project-compare-type: ANT
285               project-pattern: '{project}'
286               branches:
287                 - branch-compare-type: ANT
288                   branch-pattern: '**/{branch}'
289               <<: *lf_jjb_file_paths
290
291 - job-template:
292     name: '{project-name}-jjb-merge'
293     id: github-jjb-merge
294     <<: *lf_jjb_verify_merge
295     # yamllint disable-line rule:key-duplicates
296     <<: *lf_jjb_merge_builders
297
298     #####################
299     # Job Configuration #
300     #####################
301
302     properties:
303       - github:
304           url: '{git-url}/{github-org}/{project}'
305
306     scm:
307       - lf-infra-github-scm:
308           url: '{git-clone-url}{github-org}/{project}'
309           refspec: ''
310           branch: '{branch}'
311           submodule-recursive: '{submodule-recursive}'
312           choosing-strategy: default
313           jenkins-ssh-credential: '{jenkins-ssh-credential}'
314
315     triggers:
316       - github
317       - pollscm:
318           cron: ''
319       - lf-infra-github-pr-trigger:
320           trigger-phrase: '^remerge$'
321           only-trigger-phrase: true
322           status-context: 'JJB Merge'
323           permit-all: false
324           github-hooks: true
325           github-org: '{github-org}'
326           github_pr_whitelist: '{obj:github_pr_whitelist}'
327           github_pr_admin_list: '{obj:github_pr_admin_list}'
328
329 - job-template:
330     name: '{project-name}-jjb-verify'
331     id: github-jjb-verify
332     concurrent: true
333     <<: *lf_jjb_verify_merge
334     # yamllint disable-line rule:key-duplicates
335     <<: *lf_jjb_verify_builders
336
337     #####################
338     # Job Configuration #
339     #####################
340
341     properties:
342       - github:
343           url: '{git-url}/{github-org}/{project}'
344
345     scm:
346       - lf-infra-github-scm:
347           url: '{git-clone-url}{github-org}/{project}'
348           refspec: '+refs/pull/*:refs/remotes/origin/pr/*'
349           branch: '{branch}'
350           submodule-recursive: '{submodule-recursive}'
351           choosing-strategy: default
352           jenkins-ssh-credential: '{jenkins-ssh-credential}'
353
354     triggers:
355       - lf-infra-github-pr-trigger:
356           trigger-phrase: '^recheck$'
357           only-trigger-phrase: false
358           status-context: 'JJB Verify'
359           permit-all: true
360           github-hooks: true
361           github-org: ''
362           github_pr_whitelist:
363             - ''
364           github_pr_admin_list:
365             - ''
366
367 - job-template:
368     name: '{project-name}-packer-merge-{platforms}-{templates}'
369     id: gerrit-packer-merge
370     concurrent: true
371     <<: *lf_jjb_verify_merge
372     # yamllint disable-line rule:key-duplicates
373     <<: *lf_packer_common
374     # yamllint disable-line rule:key-duplicates
375     <<: *lf_packer_merge_builders
376
377     ######################
378     # Default parameters #
379     ######################
380
381     git-url: '$GIT_URL/$GERRIT_PROJECT'
382
383     #####################
384     # Job Configuration #
385     #####################
386
387     scm:
388       - lf-infra-gerrit-scm:
389           git-url: '{git-url}'
390           refspec: '$GERRIT_REFSPEC'
391           branch: '$GERRIT_BRANCH'
392           submodule-recursive: '{submodule-recursive}'
393           choosing-strategy: gerrit
394           jenkins-ssh-credential: '{jenkins-ssh-credential}'
395
396     triggers:
397       - gerrit:
398           server-name: '{gerrit-server-name}'
399           trigger-on:
400             - change-merged-event
401             - comment-added-contains-event:
402                 comment-contains-value: remerge$
403           projects:
404             - project-compare-type: ANT
405               project-pattern: '{project}'
406               branches:
407                 - branch-compare-type: ANT
408                   branch-pattern: '**/{branch}'
409               <<: *lf_packer_file_paths
410
411 - job-template:
412     name: '{project-name}-packer-verify'
413     id: gerrit-packer-verify
414     concurrent: true
415     <<: *lf_jjb_verify_merge
416     # yamllint disable-line rule:key-duplicates
417     <<: *lf_packer_common
418     # yamllint disable-line rule:key-duplicates
419     <<: *lf_packer_verify_builders
420
421     ######################
422     # Default parameters #
423     ######################
424
425     git-url: '$GIT_URL/$GERRIT_PROJECT'
426
427     #####################
428     # Job Configuration #
429     #####################
430
431     scm:
432       - lf-infra-gerrit-scm:
433           git-url: '{git-url}'
434           refspec: '$GERRIT_REFSPEC'
435           branch: '$GERRIT_BRANCH'
436           submodule-recursive: '{submodule-recursive}'
437           choosing-strategy: gerrit
438           jenkins-ssh-credential: '{jenkins-ssh-credential}'
439
440     triggers:
441       - gerrit:
442           server-name: '{gerrit-server-name}'
443           trigger-on:
444             - patchset-created-event:
445                 exclude-drafts: false
446                 exclude-trivial-rebase: false
447                 exclude-no-code-change: false
448             - draft-published-event
449             - comment-added-contains-event:
450                 comment-contains-value: recheck$
451           projects:
452             - project-compare-type: ANT
453               project-pattern: '{project}'
454               branches:
455                 - branch-compare-type: ANT
456                   branch-pattern: '**/{branch}'
457               <<: *lf_packer_file_paths
458
459
460 - job-template:
461     name: '{project-name}-packer-merge-{platforms}-{templates}'
462     id: github-packer-merge
463     concurrent: true
464     <<: *lf_jjb_verify_merge
465     # yamllint disable-line rule:key-duplicates
466     <<: *lf_packer_common
467     # yamllint disable-line rule:key-duplicates
468     <<: *lf_packer_merge_builders
469
470     #####################
471     # Job Configuration #
472     #####################
473
474     properties:
475       - github:
476           url: '{git-url}/{github-org}/{project}'
477
478     scm:
479       - lf-infra-github-scm:
480           url: '{git-clone-url}{github-org}/{project}'
481           refspec: ''
482           branch: '{branch}'
483           submodule-recursive: '{submodule-recursive}'
484           choosing-strategy: default
485           jenkins-ssh-credential: '{jenkins-ssh-credential}'
486
487     triggers:
488       - github
489       - pollscm:
490           cron: ''
491       - lf-infra-github-pr-trigger:
492           trigger-phrase: '^remerge$'
493           only-trigger-phrase: true
494           status-context: 'JJB Merge'
495           permit-all: false
496           github-hooks: true
497           github-org: '{github-org}'
498           github_pr_whitelist: '{obj:github_pr_whitelist}'
499           github_pr_admin_list: '{obj:github_pr_admin_list}'
500
501 - job-template:
502     name: '{project-name}-packer-verify'
503     id: github-packer-verify
504     concurrent: true
505     <<: *lf_jjb_verify_merge
506     # yamllint disable-line rule:key-duplicates
507     <<: *lf_packer_common
508     # yamllint disable-line rule:key-duplicates
509     <<: *lf_packer_verify_builders
510
511     #####################
512     # Job Configuration #
513     #####################
514
515     properties:
516       - github:
517           url: '{git-url}/{github-org}/{project}'
518
519     scm:
520       - lf-infra-github-scm:
521           url: '{git-clone-url}{github-org}/{project}'
522           refspec: '+refs/pull/*:refs/remotes/origin/pr/*'
523           branch: '{branch}'
524           submodule-recursive: '{submodule-recursive}'
525           choosing-strategy: default
526           jenkins-ssh-credential: '{jenkins-ssh-credential}'
527
528     triggers:
529       - lf-infra-github-pr-trigger:
530           trigger-phrase: '^recheck$'
531           only-trigger-phrase: false
532           status-context: 'JJB Verify'
533           permit-all: true
534           github-hooks: true
535           github-org: ''
536           github_pr_whitelist:
537             - ''
538           github_pr_admin_list:
539             - ''