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