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