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