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