Order macros alphabetically
[ci-management.git] / jjb / global-macros.yaml
1 # Copyright (c) 2020 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
5 #
6 #     http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13
14 ---
15 # Global macros.
16
17 #### PARAMETERS
18 # Keep 'parameter' entries ordered alphabetically, please.
19 - parameter:
20     name: arch-parameter
21     parameters:
22       - string:
23           name: ARCH
24           default: '{arch}'
25           description: "Architecture parameter"
26
27 - parameter:
28     name: compiler-parameter
29     parameters:
30       - string:
31           name: CC
32           default: '{cc}'
33           description: "CC parameter, can be gnu or clang"
34
35 - parameter:
36     name: csit-fail-on-crc-mismatch-parameter
37     parameters:
38       - string:
39           name: FDIO_CSIT_FAIL_ON_CRC_MISMATCH
40           default: '{fail-on-crc-mismatch}'
41           description: "If true, CRC is checked, else compatibility is tested."
42
43 - parameter:
44     name: csit-perf-trial-duration-parameter
45     parameters:
46       - string:
47           name: CSIT_PERF_TRIAL_DURATION
48           default: "{csit-perf-trial-duration}"
49           description: "Duration of a trial measurement in BMRR tests."
50
51 - parameter:
52     name: csit-perf-trial-multiplicity-parameter
53     parameters:
54       - string:
55           name: CSIT_PERF_TRIAL_MULTIPLICITY
56           default: "{csit-perf-trial-multiplicity}"
57           description: "Number of subsamples for BMRR tests."
58
59 - parameter:
60     name: gerrit-csit-refspec-parameter
61     parameters:
62       - string:
63           name: CSIT_REF
64           default: ''
65           # yamllint disable-line rule:line-length
66           description: "GERRIT_REFSPEC parameter to override separately cloned CSIT repository, leave empty for autodetection / no override."
67
68 - parameter:
69     name: gerrit-event-comment-text-parameter
70     parameters:
71       - string:
72           name: GERRIT_EVENT_COMMENT_TEXT
73           default: ''
74           # yamllint disable-line rule:line-length
75           description: "GERRIT_EVENT_COMMENT_TEXT parameter not given by trigger"
76
77 - parameter:
78     name: gerrit-event-type-parameter
79     parameters:
80       - string:
81           name: GERRIT_EVENT_TYPE
82           default: ''
83           description: "GERRIT_EVENT_TYPE parameter not given by trigger"
84
85 - parameter:
86     name: gerrit-parameter
87     parameters:
88       - string:
89           name: GERRIT_BRANCH
90           default: '{branch}'
91           description: "JJB configured GERRIT_BRANCH parameter"
92
93 - parameter:
94     name: gerrit-project-parameter
95     parameters:
96       - string:
97           name: GERRIT_PROJECT
98           default: '{project}'
99           description: "GERRIT_PROJECT parameter if not given by trigger"
100
101 - parameter:
102     name: gerrit-refspec-parameter
103     parameters:
104       - string:
105           name: GERRIT_REFSPEC
106           default: '{refspec}'
107           description: "GERRIT_REFSPEC parameter not given by trigger"
108
109 - parameter:
110     name: is-csit-vpp-job-parameter
111     parameters:
112       - string:
113           name: IS_CSIT_VPP_JOB
114           default: '{is-csit-vpp-job}'
115           description: "Parameter is True if this is a CSIT vpp job."
116
117 - parameter:
118     name: maven-exec
119     parameters:
120       - string:
121           name: MVN
122           # yamllint disable-line rule:line-length
123           default: '/w/tools/hudson.tasks.Maven_MavenInstallation/{maven-version}/bin/mvn'
124           description: 'Maven selector to be used by shell scripts'
125
126 - parameter:
127     name: maven-project-parameter
128     parameters:
129       - string:
130           name: MAVEN_SELECTOR
131           default: '{maven}'
132           description: 'Maven selector to be used by shell scripts'
133
134 - parameter:
135     name: os-parameter
136     parameters:
137       - string:
138           name: OS
139           default: '{os}'
140           description: "OS parameter"
141
142 - parameter:
143     name: project-parameter
144     parameters:
145       - string:
146           name: PROJECT
147           default: '{project}'
148           # yamllint disable-line rule:line-length
149           description: "JJB configured PROJECT parameter to identify a Gerrit project"
150
151 - parameter:
152     name: repo-name-parameter
153     parameters:
154       - string:
155           name: REPO_NAME
156           default: '{repo-name}'
157           description: 'Name of repo to which to publish packaging'
158
159 - parameter:
160     name: stream-parameter
161     parameters:
162       - string:
163           name: STREAM
164           default: '{stream}'
165           description: "Stream job parameter to be used in shell scripts."
166
167 - parameter:
168     name: topo-parameter
169     parameters:
170       - string:
171           name: TOPO
172           default: '{topo}'
173           description: "Topology parameter"
174 # [end] Keep 'parameter' entries ordered alphabetically, please.
175
176 #### SCMS
177 # Keep 'scm' entries ordered alphabetically, please.
178 - scm:
179     name: gerrit-trigger-scm
180     scm:
181       - git:
182           credentials-id: '{credentials-id}'
183           url: '$GIT_BASE'
184           refspec: '{refspec}'
185           branches:
186             - 'origin/$GERRIT_BRANCH'
187           skip-tag: true
188           choosing-strategy: '{choosing-strategy}'
189
190 - scm:
191     name: gerrit-trigger-scm-recursive
192     scm:
193       - git:
194           credentials-id: '{credentials-id}'
195           url: '$GIT_BASE'
196           refspec: '{refspec}'
197           branches:
198             - 'origin/$GERRIT_BRANCH'
199           skip-tag: true
200           choosing-strategy: '{choosing-strategy}'
201           submodule:
202             recursive: '{submodule-recursive}'
203
204 - scm:
205     name: git-scm
206     scm:
207       - git:
208           credentials-id: '{credentials-id}'
209           url: '$GIT_BASE'
210           refspec: ''
211           branches:
212             - 'origin/{branch}'
213           skip-tag: true
214           wipe-workspace: true
215 # [end] Keep 'scm' entries ordered alphabetically, please.
216
217 #### WRAPPERS
218 # Keep 'wrapper' entries ordered alphabetically, please.
219 - wrapper:
220     name: build-timeout
221     wrappers:
222       - timeout:
223           type: absolute
224           timeout: 360
225           fail: true
226
227 - wrapper:
228     # This wrapper is required for all jobs as it configures the wrappers
229     # needed by the fd.io infra.
230     name: fdio-infra-wrappers
231     wrappers:
232       - timeout:
233           type: absolute
234           timeout: '{build-timeout}'
235           timeout-var: 'BUILD_TIMEOUT'
236           fail: true
237       - timestamps
238       - ssh-agent-credentials:
239           users:
240             - 'jenkins-gerrit-credentials'
241       - jclouds:
242           single-use: true
243       - openstack:
244           single-use: true
245
246 - wrapper:
247     # This wrapper is used for all jobs that require no-activity timeouts
248     name: fdio-infra-wrappers-non-activity-timeout
249     wrappers:
250       - timeout:
251           type: no-activity
252           timeout: '{build-timeout}'
253           fail: true
254       - timestamps
255       - ssh-agent-credentials:
256           users:
257             - 'jenkins-gerrit-credentials'
258       - jclouds:
259           single-use: true
260       - openstack:
261           single-use: true
262 # [end] Keep 'wrapper' entries ordered alphabetically, please.
263
264 #### TRIGGERS
265 # Keep 'trigger' entries ordered alphabetically, please.
266 - trigger:
267     name: gerrit-trigger-checkstyle
268     # Comes from VPP, some verify jobs wait for checkstyle to pass.
269     # This macro is to be used for such verify jobs which are voting.
270     triggers:
271       - gerrit:
272           server-name: 'Primary'
273           trigger-on:
274             - comment-added-contains-event:
275                 comment-contains-value: 'checkstyle_success'
276           projects:
277             - project-compare-type: 'ANT'
278               project-pattern: '{name}'
279               branches:
280                 - branch-compare-type: 'ANT'
281                   branch-pattern: '**/{branch}'
282
283 - trigger:
284     name: gerrit-trigger-checkstyle-nonvoting
285     # Comes from VPP, some verify jobs wait for checkstyle to pass.
286     # This macro is to be used for such verify jobs which are non-voting.
287     triggers:
288       - gerrit:
289           server-name: 'Primary'
290           trigger-on:
291             - comment-added-contains-event:
292                 comment-contains-value: 'checkstyle_success'
293           projects:
294             - project-compare-type: 'ANT'
295               project-pattern: '{name}'
296               branches:
297                 - branch-compare-type: 'ANT'
298                   branch-pattern: '**/{branch}'
299           skip-vote:
300             successful: true
301             failed: true
302             unstable: true
303             notbuilt: true
304           override-votes: true
305           gerrit-build-successful-verified-value: 1
306           gerrit-build-failed-verified-value: 1
307           gerrit-build-unstable-verified-value: 1
308           gerrit-build-notbuilt-verified-value: 1
309
310 - trigger:
311     name: gerrit-trigger-csit-perftest
312     # Comes from VPP, for jobs that do performance testing using CSIT code.
313     triggers:
314       - gerrit:
315           server-name: 'Primary'
316           trigger-on:
317             - comment-added-contains-event:
318                 comment-contains-value: 'perftest-{node-arch}'
319           projects:
320             - project-compare-type: 'ANT'
321               project-pattern: '{name}'
322               branches:
323                 - branch-compare-type: 'ANT'
324                   branch-pattern: '**/{branch}'
325           skip-vote:
326             successful: true
327             failed: true
328             unstable: true
329             notbuilt: true
330
331 - trigger:
332     name: gerrit-trigger-csit-vpp-devicetest-full
333     # Comes from CSIT, for automatic jobs running "device" tests with VPP builds.
334     # The job acts as an automatic verify job for CSIT contributions.
335     triggers:
336       - gerrit:
337           server-name: 'Primary'
338           trigger-on:
339             - patchset-created-event:
340                 exclude-drafts: 'true'
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             - comment-added-contains-event:
347                 comment-contains-value: 'reverify'
348             - comment-added-contains-event:
349                 comment-contains-value: 'csit-devicetest'
350           projects:
351             - project-compare-type: 'ANT'
352               project-pattern: '{project}'
353               branches:
354                 - branch-compare-type: 'ANT'
355                   branch-pattern: '**/{branch}'
356           skip-vote:
357             successful: '{skip-vote}'
358             failed: '{skip-vote}'
359             unstable: '{skip-vote}'
360             notbuilt: '{skip-vote}'
361
362 - trigger:
363     name: gerrit-trigger-csit-vpp-devicetest-manual
364     # Comes from CSIT, for manual jobs running "device" tests with VPP builds.
365     # The job acts as a manual (optional) verify job for CSIT contributions.
366     triggers:
367       - gerrit:
368           server-name: 'Primary'
369           trigger-on:
370             - comment-added-contains-event:
371                 comment-contains-value: 'csit-devicetest'
372           projects:
373             - project-compare-type: 'ANT'
374               project-pattern: '{project}'
375               branches:
376                 - branch-compare-type: 'ANT'
377                   branch-pattern: '**/{branch}'
378           skip-vote:
379             successful: '{skip-vote}'
380             failed: '{skip-vote}'
381             unstable: '{skip-vote}'
382             notbuilt: '{skip-vote}'
383
384 - trigger:
385     name: gerrit-trigger-manually-triggered
386     triggers:
387       - gerrit:
388           server-name: 'Primary'
389           trigger-on:
390             - comment-added-contains-event:
391                 comment-contains-value: '{comment-trigger-value}'
392           projects:
393             - project-compare-type: 'ANT'
394               project-pattern: '{name}'
395               branches:
396                 - branch-compare-type: 'ANT'
397                   branch-pattern: '**/{branch}'
398
399 - trigger:
400     name: gerrit-trigger-patch-merged
401     triggers:
402       - gerrit:
403           server-name: 'Primary'
404           trigger-on:
405             - change-merged-event
406             - comment-added-contains-event:
407                 comment-contains-value: 'remerge'
408           projects:
409             - project-compare-type: 'ANT'
410               project-pattern: '{name}'
411               branches:
412                 - branch-compare-type: 'ANT'
413                   branch-pattern: '**/{branch}'
414           # Force Jenkins always vote the values it should already have voted
415           # during the prior verify phase
416           override-votes: true
417           gerrit-build-started-verified-value: 1
418           gerrit-build-successful-verified-value: 1
419           gerrit-build-failed-verified-value: 1
420           gerrit-build-unstable-verified-value: 1
421           gerrit-build-notbuilt-verified-value: 1
422           gerrit-build-started-codereview-value: 0
423           gerrit-build-successful-codereview-value: 0
424           gerrit-build-failed-codereview-value: 0
425           gerrit-build-unstable-codereview-value: 0
426           gerrit-build-notbuilt-codereview-value: 0
427
428 - trigger:
429     name: gerrit-trigger-patch-submitted
430     triggers:
431       - gerrit:
432           server-name: 'Primary'
433           trigger-on:
434             - patchset-created-event:
435                 exclude-drafts: 'true'
436                 exclude-trivial-rebase: 'false'
437                 exclude-no-code-change: 'false'
438             - draft-published-event
439             - comment-added-contains-event:
440                 comment-contains-value: 'recheck'
441             - comment-added-contains-event:
442                 comment-contains-value: 'reverify'
443           projects:
444             - project-compare-type: 'ANT'
445               project-pattern: '{name}'
446               branches:
447                 - branch-compare-type: 'ANT'
448                   branch-pattern: '**/{branch}'
449
450 - trigger:
451     name: gerrit-trigger-os-patch-merged
452     triggers:
453       - gerrit:
454           server-name: 'Primary'
455           trigger-on:
456             - comment-added-contains-event:
457                 comment-contains-value: 'os-merge'
458           projects:
459             - project-compare-type: 'ANT'
460               project-pattern: '{name}'
461               branches:
462                 - branch-compare-type: 'ANT'
463                   branch-pattern: '**/{branch}'
464           # Force Jenkins always vote the values it should already have voted
465           # during the prior verify phase
466           override-votes: true
467           gerrit-build-started-verified-value: 1
468           gerrit-build-successful-verified-value: 1
469           gerrit-build-failed-verified-value: 1
470           gerrit-build-unstable-verified-value: 1
471           gerrit-build-notbuilt-verified-value: 1
472           gerrit-build-started-codereview-value: 0
473           gerrit-build-successful-codereview-value: 0
474           gerrit-build-failed-codereview-value: 0
475           gerrit-build-unstable-codereview-value: 0
476           gerrit-build-notbuilt-codereview-value: 0
477
478 - trigger:
479     name: gerrit-trigger-os-trivial-patch-submitted
480     triggers:
481       - gerrit:
482           server-name: 'Primary'
483           trigger-on:
484             - comment-added-contains-event:
485                 comment-contains-value: 'os-check'
486             - comment-added-contains-event:
487                 comment-contains-value: 'os-verify'
488           projects:
489             - project-compare-type: 'ANT'
490               project-pattern: '{name}'
491               branches:
492                 - branch-compare-type: 'ANT'
493                   branch-pattern: '**/{branch}'
494
495 - trigger:
496     name: gerrit-trigger-trivial-patch-submitted
497     triggers:
498       - gerrit:
499           server-name: 'Primary'
500           trigger-on:
501             - patchset-created-event:
502                 exclude-drafts: 'true'
503                 exclude-trivial-rebase: 'false'
504                 exclude-no-code-change: 'true'
505             - draft-published-event
506             - comment-added-contains-event:
507                 comment-contains-value: 'recheck'
508             - comment-added-contains-event:
509                 comment-contains-value: 'reverify'
510           projects:
511             - project-compare-type: 'ANT'
512               project-pattern: '{name}'
513               branches:
514                 - branch-compare-type: 'ANT'
515                   branch-pattern: '**/{branch}'
516
517 - trigger:
518     name: gerrit-trigger-trivial-patch-submitted-skip-vote
519     triggers:
520       - gerrit:
521           server-name: 'Primary'
522           trigger-on:
523             - patchset-created-event:
524                 exclude-drafts: 'true'
525                 exclude-trivial-rebase: 'false'
526                 exclude-no-code-change: 'true'
527             - draft-published-event
528             - comment-added-contains-event:
529                 comment-contains-value: 'recheck'
530             - comment-added-contains-event:
531                 comment-contains-value: 'reverify'
532           projects:
533             - project-compare-type: 'ANT'
534               project-pattern: '{name}'
535               branches:
536                 - branch-compare-type: 'ANT'
537                   branch-pattern: '**/{branch}'
538           skip-vote:
539             successful: true
540             failed: true
541             unstable: true
542             notbuilt: true
543
544 - trigger:
545     name: gerrit-trigger-vpp-csit-devicetest-full
546     # Comes from VPP, for automated jobs running "device" tests with CSIT code.
547     # The job acts as an automatic verify job for VPP contributions.
548     triggers:
549       - gerrit:
550           server-name: 'Primary'
551           trigger-on:
552             - comment-added-contains-event:
553                 comment-contains-value: 'checkstyle_success'
554             - comment-added-contains-event:
555                 comment-contains-value: 'devicetest'
556           projects:
557             - project-compare-type: 'ANT'
558               project-pattern: '{name}'
559               branches:
560                 - branch-compare-type: 'ANT'
561                   branch-pattern: '**/{branch}'
562           skip-vote:
563             successful: '{skip-vote}'
564             failed: '{skip-vote}'
565             unstable: '{skip-vote}'
566             notbuilt: '{skip-vote}'
567
568 - trigger:
569     name: gerrit-trigger-vpp-csit-devicetest-manual
570     # Comes from VPP, for manual jobs running "device" tests with CSIT code.
571     # The job acts as a manual (optional) verify job for VPP contributions.
572     triggers:
573       - gerrit:
574           server-name: 'Primary'
575           trigger-on:
576             - comment-added-contains-event:
577                 comment-contains-value: 'devicetest'
578           projects:
579             - project-compare-type: 'ANT'
580               project-pattern: '{name}'
581               branches:
582                 - branch-compare-type: 'ANT'
583                   branch-pattern: '**/{branch}'
584           skip-vote:
585             successful: '{skip-vote}'
586             failed: '{skip-vote}'
587             unstable: '{skip-vote}'
588             notbuilt: '{skip-vote}'
589 # [end] Keep 'trigger' entries ordered alphabetically, please.
590
591 #### PUBLISHERS
592 # Keep 'publisher' entries ordered alphabetically, please.
593 - publisher:
594     name: archive-artifacts
595     publishers:
596       - archive:
597           artifacts: '{artifacts}'
598           allow-empty: true
599           fingerprint: true
600           latest-only: true
601
602 - publisher:
603     name: email-notification
604     publishers:
605       - email-ext:
606           recipients: 'nobody@projectrotterdam.info'
607           reply-to: ''
608           content-type: default
609           # yamllint disable-line rule:line-length
610           subject: '{email-prefix} $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!'
611           body: |
612               $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS:
613
614               Check console output at $BUILD_URL to view the results.
615           unstable: true
616           fixed: true
617           send-to:
618             - developers
619             - recipients
620
621 - publisher:
622     name: fdio-infra-shiplogs
623     # To archive things, the job will need to create an "archives" directory in
624     # the workspace and this macro will handle copying the contents of the
625     # archives directory.
626     #
627     # Uses the build parameter ARCHIVE_ARTIFACTS if not empty to find files to
628     # archive. You can pass globstar patterns for example "**/*.xml **/*.log" as
629     # the archive pattern. This is a space separated list of files to archive.
630     #
631     # Also ensure that the workspace is cleaned up at the end of the build.
632     publishers:
633       - postbuildscript:
634           builders:
635             - role: BOTH
636               build-on:
637                 - ABORTED
638                 - FAILURE
639                 - NOT_BUILT
640                 - SUCCESS
641                 - UNSTABLE
642               build-steps:
643                 - shell: !include-raw: include-raw-deploy-archives.sh
644                 - maven-target:
645                     maven-version: '{maven-version}'
646                     pom: '.archives/deploy-archives.xml'
647                     goals: 'clean deploy -V -B -q -Dmaven.repo.local=/tmp/r'
648                     settings: 'jenkins-log-archives-settings'
649                     settings-type: cfp
650                     global-settings: 'global-settings'
651                     global-settings-type: cfp
652                 - description-setter:
653                     regexp: '^Build logs: .*'
654           mark-unstable-if-failed: true
655       - workspace-cleanup:
656           fail-build: false
657
658 - publisher:
659     name: jacoco-report
660     publishers:
661       - jacoco:
662           exec-pattern: '**/**.exec'
663           class-pattern: '**/classes'
664           source-pattern: '**/src/main/java'
665           # yamllint disable-line rule:line-length
666           exclusion-pattern: '**/gen**,**/generated-sources/**,**/yang-gen**,**/pax/**'
667           status-update: true
668           targets:
669             - branch:
670               healthy: 10
671               unhealthy: 20
672             - method:
673               healthy: 50
674               unhealthy: 40
675
676 - publisher:
677     name: retry-build-on-builder-error
678     publishers:
679       - naginator:
680           max-failed-builds: 1
681
682 - publisher:
683     name: robot-report
684     publishers:
685       - robot:
686           output-path: '{output-path}'
687           other-files: ''
688 # [end] Keep 'publisher' entries ordered alphabetically, please.
689
690 #### BUILDERS
691 # Keep 'builder' entries ordered alphabetically, please.
692 - builder:
693     name: ci-management-check-unicode
694     builders:
695       - shell: |
696           $WORKSPACE/scripts/check-unicode.sh jjb/
697
698 - property:
699     name: fdio-infra-properties
700     properties:
701       - build-discarder:
702           days-to-keep: '{build-days-to-keep}'
703           num-to-keep: '{build-num-to-keep}'
704
705 - builder:
706     name: packer-validate
707     builders:
708       - config-file-provider:
709           files:
710             - file-id: 'packer-cloud-env'
711               variable: 'CLOUDENV'
712       # yamllint disable rule:line-length
713       - shell: |
714           #!/bin/bash
715           cd packer
716           varfiles="../packer/vars/*"
717           templates="../packer/templates/*"
718           provision="../packer/provision/*.sh"
719           for v in $varfiles; do
720               [[ "${v##*/}" =~ ^(cloud-env.*)$ ]] && continue
721               for t in $templates; do
722                   export PACKER_LOG="yes" && \
723                   export PACKER_LOG_PATH="packer-validate-${v##*/}-${t##*/}.log" && \
724                               packer.io validate -var-file=$CLOUDENV \
725                               -var-file=$v $t
726                   if [ $? -ne 0 ]; then
727                      break
728                   fi
729               done
730           done
731           for p in $provision; do
732               /bin/bash -n $p > provision-validate-${p##*/}.log 2>&1
733               if [ $? -ne 0 ]; then
734                  break
735               fi
736           done
737       # yamllint enable
738
739 - builder:
740     name: packer-build
741     builders:
742       - config-file-provider:
743           files:
744             - file-id: 'packer-cloud-env'
745               variable: 'CLOUDENV'
746       - shell: |
747           #!/bin/bash
748           cd packer
749           export PACKER_LOG="yes" && \
750           export PACKER_LOG_PATH="packer-build.log" && \
751                       packer.io build -var-file=$CLOUDENV \
752                       -var-file=../packer/vars/{platform}.json \
753                       ../packer/templates/{template}.json
754
755 - builder:
756     name: provide-maven-settings
757     builders:
758       - config-file-provider:
759           files:
760             - file-id: '{global-settings-file}'
761               variable: 'GLOBAL_SETTINGS_FILE'
762             - file-id: '{settings-file}'
763               variable: 'SETTINGS_FILE'
764 # [end] Keep 'builder' entries ordered alphabetically, please.