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