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