Merge "Correction in script for building longbow docs"
[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-trivial-patch-submitted-skip-vote
221     triggers:
222         - gerrit:
223             server-name: 'Primary'
224             trigger-on:
225                 - patchset-created-event:
226                     exclude-drafts: 'false'
227                     exclude-trivial-rebase: 'true'
228                     exclude-no-code-change: 'true'
229                 - draft-published-event
230                 - comment-added-contains-event:
231                     comment-contains-value: 'recheck'
232                 - comment-added-contains-event:
233                     comment-contains-value: 'reverify'
234             projects:
235                 - project-compare-type: 'ANT'
236                   project-pattern: '{name}'
237                   branches:
238                     - branch-compare-type: 'ANT'
239                       branch-pattern: '**/{branch}'
240             skip-vote:
241                 successful: true
242                 failed: true
243                 unstable: true
244                 notbuilt: true
245
246 - trigger:
247     name: gerrit-trigger-manually-triggered
248     triggers:
249         - gerrit:
250             server-name: 'Primary'
251             trigger-on:
252                 - comment-added-contains-event:
253                     comment-contains-value: '{comment-trigger-value}'
254             projects:
255                 - project-compare-type: 'ANT'
256                   project-pattern: '{name}'
257                   branches:
258                     - branch-compare-type: 'ANT'
259                       branch-pattern: '**/{branch}'
260
261 - trigger:
262     name: gerrit-trigger-patch-merged
263     triggers:
264         - gerrit:
265             server-name: 'Primary'
266             trigger-on:
267                 - change-merged-event
268                 - comment-added-contains-event:
269                     comment-contains-value: 'remerge'
270             projects:
271                 - project-compare-type: 'ANT'
272                   project-pattern: '{name}'
273                   branches:
274                     - branch-compare-type: 'ANT'
275                       branch-pattern: '**/{branch}'
276             # Force Jenkins always vote the values it should already have voted
277             # during the prior verify phase
278             override-votes: true
279             gerrit-build-started-verified-value: 1
280             gerrit-build-successful-verified-value: 1
281             gerrit-build-failed-verified-value: 1
282             gerrit-build-unstable-verified-value: 1
283             gerrit-build-notbuilt-verified-value: 1
284             gerrit-build-started-codereview-value: 0
285             gerrit-build-successful-codereview-value: 0
286             gerrit-build-failed-codereview-value: 0
287             gerrit-build-unstable-codereview-value: 0
288             gerrit-build-notbuilt-codereview-value: 0
289
290 # Publishers
291 - publisher:
292     name: archive-artifacts
293     publishers:
294         - archive:
295             artifacts: '{artifacts}'
296             allow-empty: true
297             fingerprint: true
298             latest-only: true
299
300 - publisher:
301     name: email-notification
302     publishers:
303         - email-ext:
304             recipients: 'nobody@projectrotterdam.info'
305             reply-to: ''
306             content-type: default
307             subject: '{email-prefix} $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!'
308             body: |
309                 $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS:
310
311                 Check console output at $BUILD_URL to view the results.
312             unstable: true
313             fixed: true
314             send-to:
315                 - developers
316                 - recipients
317
318 - publisher:
319     name: jacoco-report
320     publishers:
321         - jacoco:
322             exec-pattern: '**/**.exec'
323             class-pattern: '**/classes'
324             source-pattern: '**/src/main/java'
325             exclusion-pattern: '**/gen**,**/generated-sources/**,**/yang-gen**,**/pax/**'
326             status-update: true
327             targets:
328                 - branch:
329                     healthy: 10
330                     unhealthy: 20
331                 - method:
332                     healthy: 50
333                     unhealthy: 40
334
335 - publisher:
336     name: robot-report
337     publishers:
338         - robot:
339             output-path: '{output-path}'
340             other-files: ''
341
342 - publisher:
343     name: fdio-infra-shiplogs
344     # To archive things, the job will need to create an "archives" directory in
345     # the workspace and this macro will handle copying the contents of the
346     # archives directory.
347     #
348     # Uses the build parameter ARCHIVE_ARTIFACTS if not empty to find files to
349     # archive. You can pass globstar patterns for example "**/*.xml **/*.log" as
350     # the archive pattern. This is a space separated list of files to archive.
351     #
352     # Also ensure that the workspace is cleaned up at the end of the build.
353     publishers:
354       - postbuildscript:
355           builders:
356             - shell: !include-raw: include-raw-deploy-archives.sh
357             - maven-target:
358                 maven-version: '{maven-version}'
359                 pom: '.archives/deploy-archives.xml'
360                 goals: 'clean deploy -V -B -q -Dmaven.repo.local=/tmp/r'
361                 settings: 'jenkins-log-archives-settings'
362                 settings-type: cfp
363                 global-settings: 'global-settings'
364                 global-settings-type: cfp
365             - description-setter:
366                 regexp: '^Build logs: .*'
367           script-only-if-succeeded: false
368           script-only-if-failed: false
369           mark-unstable-if-failed: true
370       - workspace-cleanup:
371           fail-build: false
372
373 - publisher:
374     name: retry-build-on-builder-error
375     publishers:
376       - naginator:
377           max-failed-builds: 1
378
379 ###### BUILDERS
380 - builder:
381     name: ci-management-check-unicode
382     builders:
383         - shell: |
384             $WORKSPACE/scripts/check-unicode.sh jjb/
385
386 - builder:
387     name: provide-maven-settings
388     builders:
389         - config-file-provider:
390             files:
391                 - file-id: '{global-settings-file}'
392                   variable: 'GLOBAL_SETTINGS_FILE'
393                 - file-id: '{settings-file}'
394                   variable: 'SETTINGS_FILE'
395
396 - property:
397     name: fdio-infra-properties
398     properties:
399         - build-discarder:
400             days-to-keep: '{build-days-to-keep}'
401             num-to-keep: '{build-num-to-keep}'
402
403
404 - builder:
405     name: packer-validate
406     builders:
407         - config-file-provider:
408             files:
409                 - file-id: 'packer-cloud-env'
410                   variable: 'CLOUDENV'
411         - shell: |
412             #!/bin/bash
413             cd packer
414             varfiles="../packer/vars/*"
415             templates="../packer/templates/*"
416             provision="../packer/provision/*.sh"
417             for v in $varfiles; do
418                 [[ "${v##*/}" =~ ^(cloud-env.*)$ ]] && continue
419                 for t in $templates; do
420                     export PACKER_LOG="yes" && \
421                     export PACKER_LOG_PATH="packer-validate-${v##*/}-${t##*/}.log" && \
422                                 packer.io validate -var-file=$CLOUDENV \
423                                 -var-file=$v $t
424                     if [ $? -ne 0 ]; then
425                         break
426                     fi
427                 done
428             done
429             for p in $provision; do
430                 /bin/bash -n $p > provision-validate-${p##*/}.log 2>&1
431                 if [ $? -ne 0 ]; then
432                     break
433                 fi
434             done
435
436
437 - builder:
438     name: packer-build
439     builders:
440         - config-file-provider:
441             files:
442                 - file-id: 'packer-cloud-env'
443                   variable: 'CLOUDENV'
444         - shell: |
445             #!/bin/bash
446             cd packer
447             export PACKER_LOG="yes" && \
448             export PACKER_LOG_PATH="packer-build.log" && \
449                         packer.io build -var-file=$CLOUDENV \
450                          -var-file=../packer/vars/{platform}.json \
451                          ../packer/templates/{template}.json