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