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