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