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