Merge "VPP: Remove older and no longer supported versions from stream"
[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
93 ##### SCMS
94 - scm:
95     name: git-scm
96     scm:
97         - git:
98             credentials-id: '{credentials-id}'
99             url: '$GIT_BASE'
100             refspec: ''
101             branches:
102                 - 'origin/{branch}'
103             skip-tag: true
104             wipe-workspace: true
105
106 - scm:
107     name: gerrit-trigger-scm
108     scm:
109         - git:
110             credentials-id: '{credentials-id}'
111             url: '$GIT_BASE'
112             refspec: '{refspec}'
113             branches:
114                 - 'origin/$GERRIT_BRANCH'
115             skip-tag: true
116             choosing-strategy: '{choosing-strategy}'
117
118 - scm:
119     name: zuul-trigger-scm
120     scm:
121       - git:
122           url: '$ZUUL_URL/$ZUUL_PROJECT'
123           refspec: '{refspec}'
124           branches:
125             - '{commit}'
126           skip-tag: true
127           wipe-workspace: true
128
129 ###### WRAPPERS
130 - wrapper:
131     name: build-timeout
132     wrappers:
133         - timeout:
134             type: absolute
135             timeout: 360
136             fail: true
137
138 - wrapper:
139     # This wrapper is used for all jobs that require no-activity timeouts
140     name: fdio-infra-wrappers-non-activity-timeout
141     wrappers:
142       - timeout:
143           type: no-activity
144           timeout: '{build-timeout}'
145           fail: true
146       - timestamps
147       - ssh-agent-credentials:
148           users:
149             - 'jenkins-gerrit-credentials'
150       - jclouds:
151           single-use: True
152       - openstack:
153           single-use: True
154
155 - wrapper:
156     # This wrapper is required for all jobs as it configures the wrappers
157     # needed by the fd.io infra.
158     name: fdio-infra-wrappers
159     wrappers:
160       - timeout:
161           type: absolute
162           timeout: '{build-timeout}'
163           timeout-var: 'BUILD_TIMEOUT'
164           fail: true
165       - timestamps
166       - ssh-agent-credentials:
167           users:
168               - 'jenkins-gerrit-credentials'
169       - jclouds:
170           single-use: True
171       - openstack:
172           single-use: True
173
174 ###### TRIGGERS
175 - trigger:
176     name: gerrit-trigger-patch-submitted
177     triggers:
178         - gerrit:
179             server-name: 'Primary'
180             trigger-on:
181                 - patchset-created-event:
182                     exclude-drafts: 'false'
183                     exclude-trivial-rebase: 'false'
184                     exclude-no-code-change: 'false'
185                 - draft-published-event
186                 - comment-added-contains-event:
187                     comment-contains-value: 'recheck'
188                 - comment-added-contains-event:
189                     comment-contains-value: 'reverify'
190             projects:
191                 - project-compare-type: 'ANT'
192                   project-pattern: '{name}'
193                   branches:
194                     - branch-compare-type: 'ANT'
195                       branch-pattern: '**/{branch}'
196
197 - trigger:
198     name: gerrit-trigger-trivial-patch-submitted
199     triggers:
200         - gerrit:
201             server-name: 'Primary'
202             trigger-on:
203                 - patchset-created-event:
204                     exclude-drafts: 'false'
205                     exclude-trivial-rebase: 'true'
206                     exclude-no-code-change: 'true'
207                 - draft-published-event
208                 - comment-added-contains-event:
209                     comment-contains-value: 'recheck'
210                 - comment-added-contains-event:
211                     comment-contains-value: 'reverify'
212             projects:
213                 - project-compare-type: 'ANT'
214                   project-pattern: '{name}'
215                   branches:
216                     - branch-compare-type: 'ANT'
217                       branch-pattern: '**/{branch}'
218
219 - trigger:
220     name: gerrit-trigger-manually-triggered
221     triggers:
222         - gerrit:
223             server-name: 'Primary'
224             trigger-on:
225                 - comment-added-contains-event:
226                     comment-contains-value: '{comment-trigger-value}'
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-patch-merged
236     triggers:
237         - gerrit:
238             server-name: 'Primary'
239             trigger-on:
240                 - change-merged-event
241                 - comment-added-contains-event:
242                     comment-contains-value: 'remerge'
243             projects:
244                 - project-compare-type: 'ANT'
245                   project-pattern: '{name}'
246                   branches:
247                     - branch-compare-type: 'ANT'
248                       branch-pattern: '**/{branch}'
249             # Force Jenkins always vote the values it should already have voted
250             # during the prior verify phase
251             override-votes: true
252             gerrit-build-started-verified-value: 1
253             gerrit-build-successful-verified-value: 1
254             gerrit-build-failed-verified-value: 1
255             gerrit-build-unstable-verified-value: 1
256             gerrit-build-notbuilt-verified-value: 1
257             gerrit-build-started-codereview-value: 0
258             gerrit-build-successful-codereview-value: 0
259             gerrit-build-failed-codereview-value: 0
260             gerrit-build-unstable-codereview-value: 0
261             gerrit-build-notbuilt-codereview-value: 0
262
263 # Publishers
264 - publisher:
265     name: archive-artifacts
266     publishers:
267         - archive:
268             artifacts: '{artifacts}'
269             allow-empty: true
270             fingerprint: true
271             latest-only: true
272
273 - publisher:
274     name: email-notification
275     publishers:
276         - email-ext:
277             recipients: 'nobody@projectrotterdam.info'
278             reply-to: ''
279             content-type: default
280             subject: '{email-prefix} $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!'
281             body: |
282                 $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS:
283
284                 Check console output at $BUILD_URL to view the results.
285             unstable: true
286             fixed: true
287             send-to:
288                 - developers
289                 - recipients
290
291 - publisher:
292     name: jacoco-report
293     publishers:
294         - jacoco:
295             exec-pattern: '**/**.exec'
296             class-pattern: '**/classes'
297             source-pattern: '**/src/main/java'
298             exclusion-pattern: '**/gen**,**/generated-sources/**,**/yang-gen**,**/pax/**'
299             status-update: true
300             targets:
301                 - branch:
302                     healthy: 10
303                     unhealthy: 20
304                 - method:
305                     healthy: 50
306                     unhealthy: 40
307
308 - publisher:
309     name: robot-report
310     publishers:
311         - robot:
312             output-path: '{output-path}'
313             other-files: ''
314
315 - publisher:
316     name: fdio-infra-shiplogs
317     # To archive things, the job will need to create an "archives" directory in
318     # the workspace and this macro will handle copying the contents of the
319     # archives directory.
320     #
321     # Uses the build parameter ARCHIVE_ARTIFACTS if not empty to find files to
322     # archive. You can pass globstar patterns for example "**/*.xml **/*.log" as
323     # the archive pattern. This is a space separated list of files to archive.
324     #
325     # Also ensure that the workspace is cleaned up at the end of the build.
326     publishers:
327       - postbuildscript:
328           builders:
329             - shell: !include-raw: include-raw-deploy-archives.sh
330             - maven-target:
331                 maven-version: '{maven-version}'
332                 pom: '.archives/deploy-archives.xml'
333                 goals: 'clean deploy -V -B -q -Dmaven.repo.local=/tmp/r'
334                 settings: 'jenkins-log-archives-settings'
335                 settings-type: cfp
336                 global-settings: 'global-settings'
337                 global-settings-type: cfp
338             - description-setter:
339                 regexp: '^Build logs: .*'
340           script-only-if-succeeded: false
341           script-only-if-failed: false
342           mark-unstable-if-failed: true
343       - workspace-cleanup:
344           fail-build: false
345
346 - publisher:
347     name: retry-build-on-builder-error
348     publishers:
349       - naginator:
350           max-failed-builds: 1
351
352 ###### BUILDERS
353 - builder:
354     name: ci-management-check-unicode
355     builders:
356         - shell: |
357             $WORKSPACE/scripts/check-unicode.sh jjb/
358
359 - builder:
360     name: provide-maven-settings
361     builders:
362         - config-file-provider:
363             files:
364                 - file-id: '{global-settings-file}'
365                   variable: 'GLOBAL_SETTINGS_FILE'
366                 - file-id: '{settings-file}'
367                   variable: 'SETTINGS_FILE'
368
369 - property:
370     name: fdio-infra-properties
371     properties:
372         - build-discarder:
373             days-to-keep: '{build-days-to-keep}'
374             num-to-keep: '{build-num-to-keep}'
375
376
377 - builder:
378     name: packer-validate
379     builders:
380         - config-file-provider:
381             files:
382                 - file-id: 'packer-cloud-env'
383                   variable: 'CLOUDENV'
384         - shell: |
385             #!/bin/bash
386             cd packer
387             varfiles="../packer/vars/*"
388             templates="../packer/templates/*"
389             provision="../packer/provision/*.sh"
390             for v in $varfiles; do
391                 [[ "${v##*/}" =~ ^(cloud-env.*)$ ]] && continue
392                 for t in $templates; do
393                     export PACKER_LOG="yes" && \
394                     export PACKER_LOG_PATH="packer-validate-${v##*/}-${t##*/}.log" && \
395                                 packer.io validate -var-file=$CLOUDENV \
396                                 -var-file=$v $t
397                     if [ $? -ne 0 ]; then
398                         break
399                     fi
400                 done
401             done
402             for p in $provision; do
403                 /bin/bash -n $p > provision-validate-${p##*/}.log 2>&1
404                 if [ $? -ne 0 ]; then
405                     break
406                 fi
407             done
408
409
410 - builder:
411     name: packer-build
412     builders:
413         - config-file-provider:
414             files:
415                 - file-id: 'packer-cloud-env'
416                   variable: 'CLOUDENV'
417         - shell: |
418             #!/bin/bash
419             cd packer
420             export PACKER_LOG="yes" && \
421             export PACKER_LOG_PATH="packer-build.log" && \
422                         packer.io build -var-file=$CLOUDENV \
423                          -var-file=../packer/vars/{platform}.json \
424                          ../packer/templates/{template}.json