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