Update format of postbuildscript call
[ci-management.git] / jjb / global-macros.yaml
1 ---
2 # Global macros
3
4 # vim: sw=2 ts=2 sts=2 et :
5
6 # BUILDERS
7 - builder:
8     name: ci-management-check-unicode
9     builders:
10       - shell: |
11           $WORKSPACE/scripts/check-unicode.sh jjb/
12
13 - builder:
14     name: provide-maven-settings
15     builders:
16       - config-file-provider:
17           files:
18             - file-id: '{global-settings-file}'
19               variable: 'GLOBAL_SETTINGS_FILE'
20             - file-id: '{settings-file}'
21               variable: 'SETTINGS_FILE'
22
23 # call maven-target builder with a goal of --version to force Jenkins to
24 # install the needed maven version
25 - builder:
26     name: maven-install
27     builders:
28       - maven-target:
29           maven-version: '{maven-version}'
30           goals: '--version'
31
32 - builder:
33     name: maven-docker-push-release
34     builders:
35       - maven-target:
36           maven-version: '{maven-version}'
37           pom: '{pom}'
38           goals: 'clean deploy -B -P {mvn-profile}'
39           settings: '{mvn-settings}'
40           settings-type: cfp
41           global-settings: 'global-settings'
42           global-settings-type: cfp
43           properties:
44             - maven.test.skip=true
45             - docker.pull.registry=nexus3.onap.org:10001
46             - docker.push.registry=nexus3.onap.org:10002
47
48 - builder:
49     name: maven-docker-push-daily
50     builders:
51       - maven-target:
52           maven-version: '{maven-version}'
53           pom: '{pom}'
54           goals: 'clean deploy -B -P {mvn-profile}'
55           settings: '{mvn-settings}'
56           settings-type: cfp
57           global-settings: 'global-settings'
58           global-settings-type: cfp
59           properties:
60             - maven.test.skip=true
61             - docker.pull.registry=nexus3.onap.org:10001
62             - docker.push.registry=nexus3.onap.org:10003
63
64 - builder:
65     name: maven-docker-push-daily-test
66     builders:
67       - maven-target:
68           maven-version: '{maven-version}'
69           pom: '{pom}'
70           goals: 'clean deploy -B -P {mvn-profile}'
71           settings: '{mvn-settings}'
72           settings-type: cfp
73           global-settings: 'global-settings'
74           global-settings-type: cfp
75           properties:
76             - docker.pull.registry=nexus3.onap.org:10001
77             - docker.push.registry=nexus3.onap.org:10003
78
79 - builder:
80     name: docker-login
81     builders:
82       - shell: !include-raw: include-docker-login.sh
83
84 - builder:
85     name: publish-pypi
86     builders:
87       - inject:
88           properties-content: PYPI_SERVER={pypi-server}
89       - shell:
90           !include-raw-escape: ../shell/pypi-publish.sh
91
92 # PARAMETERS
93 - parameter:
94     name: infra-parameters
95     parameters:
96       - string:
97           name: PROJECT
98           default: '{project}'
99           # yamllint disable rule:line-length
100           description: 'JJB configured PROJECT parameter to identify a Gerrit project'
101           # yamllint enable
102       - string:
103           name: ARCHIVE_ARTIFACTS
104           default: '{artifacts} **/target/surefire-reports/*-output.txt'
105           # yamllint disable rule:line-length
106           description: 'Space separated glob patterns for artifacts to archive to logs hosting'
107           # yamllint enable
108       - string:
109           name: GERRIT_BRANCH
110           default: '{branch}'
111           description: 'JJB configured GERRIT_BRANCH parameter'
112       - string:
113           name: GERRIT_PROJECT
114           default: '{project}'
115           description: 'GERRIT_PROJECT parameter if not given by trigger'
116       - string:
117           name: GERRIT_REFSPEC
118           default: '{refspec}'
119           description: 'GERRIT_REFSPEC parameter if not given by trigger'
120       - string:
121           name: STACK_NAME
122           default: '$JOB_NAME-$BUILD_NUMBER'
123           description: 'Used by Heat to generate a unique stack & vm name'
124
125 - parameter:
126     name: maven-params
127     parameters:
128       - string:
129           name: MAVEN_PARAMS
130           default: '{mvn-params}'
131           description: Maven parameters to pass to the mvn command.
132
133 - parameter:
134     name: maven-exec
135     parameters:
136       - string:
137           name: MVN
138           # yamllint disable rule:line-length
139           default: '/w/tools/hudson.tasks.Maven_MavenInstallation/{maven-version}/bin/mvn'
140           # yamllint enable
141           description: 'Maven selector to be used by shell scripts'
142
143 - parameter:
144     name: docker-image-name
145     parameters:
146       - string:
147           name: DOCKER_IMAGE_NAME
148           # yamllint disable rule:line-length
149           default: '{docker-image-name}'
150           # yamllint enable
151           description: 'Docker image name, e.g. onap/appc'
152
153 # PROPERTIES
154 - property:
155     name: infra-properties
156     properties:
157       - build-discarder:
158           days-to-keep: '{build-days-to-keep}'
159           num-to-keep: 40
160           artifact-days-to-keep: -1
161           artifact-num-to-keep: 5
162
163 # PUBLISHERS
164 - publisher:
165     name: archive-artifacts
166     publishers:
167       - archive:
168           artifacts: '{artifacts}'
169           allow-empty: true
170           fingerprint: true
171           latest-only: true
172
173 - publisher:
174     name: email-notification
175     publishers:
176       - email-ext:
177           recipients: 'nobody@open-o.org'
178           reply-to:
179           content-type: default
180           # yamllint disable rule:line-length
181           subject: '{email-prefix} $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!'
182           # yamllint enable
183           body: |
184             $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS:
185
186             Check console output at $BUILD_URL to view the results.
187           unstable: true
188           fixed: true
189           send-to:
190             - developers
191             - recipients
192
193 - publisher:
194     name: jacoco-report
195     publishers:
196       - jacoco:
197           exec-pattern: '**/**.exec'
198           class-pattern: '**/classes'
199           source-pattern: '**/src/main/java'
200           # yamllint disable rule:line-length
201           exclusion-pattern: '**/gen**,**/generated-sources/**,**/yang-gen**,**/pax/**'
202           # yamllint enable
203           status-update: true
204           targets:
205             - branch:
206                 healthy: 10
207                 unhealthy: 20
208             - method:
209                 healthy: 50
210                 unhealthy: 40
211
212 - publisher:
213     name: checkstyle-result
214     publishers:
215       - checkstyle:
216           pattern: '**/checkstyle-result.xml'
217           healthy: 0
218           unhealthy: 100
219           health-threshold: 'high'
220           thresholds:
221             unstable:
222               total-all: 30
223               total-high: 15
224               total-normal: 20
225               total-low: 25
226               new-all: 5
227               new-high: 0
228               new-normal: 2
229               new-low: 5
230
231 - publisher:
232     name: checkstyle-result-daily
233     publishers:
234       - checkstyle:
235           pattern: '**/checkstyle-result.xml'
236           healthy: 0
237           unhealthy: 100
238           health-threshold: 'high'
239           thresholds:
240             unstable:
241               total-all: 30
242               total-high: 15
243               total-normal: 20
244               total-low: 25
245               new-all: 1
246               new-high: 0
247               new-normal: 1
248               new-low: 1
249
250 - publisher:
251     name: infra-shiplogs
252     # lf-infra macro to finish up a build.
253     #
254     # Handles the following:
255     #   - Shipping logs to Nexus logs site repository
256     #   - Cleanup workspace
257     publishers:
258       - postbuildscript:
259           builders:
260             - role: BOTH
261               build-on:
262                 - ABORTED
263                 - FAILURE
264                 - NOT_BUILT
265                 - SUCCESS
266                 - UNSTABLE
267               build-steps:
268                 - lf-infra-sysstat
269                 - lf-infra-ship-logs
270           mark-unstable-if-failed: true
271       - workspace-cleanup:
272           exclude:
273             # Do not clean up *.jenkins-trigger files for jobs that use a
274             # properties file as input for triggering another build.
275             - '**/*.jenkins-trigger'
276           fail-build: false
277
278
279 # SCMS
280 - scm:
281     name: git-scm
282     scm:
283       - git:
284           credentials-id: 'onap-jenkins-ssh'
285           url: '$GIT_BASE'
286           refspec: ''
287           branches:
288             - 'origin/{branch}'
289           skip-tag: true
290           wipe-workspace: true
291           timeout: 30
292
293 - scm:
294     name: gerrit-trigger-scm
295     scm:
296       - git:
297           credentials-id: 'onap-jenkins-ssh'
298           url: '$GIT_BASE'
299           refspec: '{refspec}'
300           branches:
301             - 'origin/$GERRIT_BRANCH'
302           skip-tag: true
303           timeout: 30
304           choosing-strategy: '{choosing-strategy}'
305           submodule:
306             recursive: '{submodule-recursive}'
307
308 - scm:
309     name: gerrit-trigger-scm-basedir
310     scm:
311       - git:
312           credentials-id: 'onap-jenkins-ssh'
313           url: '$GIT_BASE'
314           refspec: '{refspec}'
315           branches:
316             - 'origin/$GERRIT_BRANCH'
317           skip-tag: true
318           timeout: 30
319           choosing-strategy: '{choosing-strategy}'
320           basedir: '{basedir}'
321
322 - scm:
323     name: git-branch-scm
324     scm:
325       - git:
326           credentials-id: 'onap-jenkins-ssh'
327           url: '$GIT_BASE'
328           refspec: ''
329           branches:
330             - 'origin/{branch}'
331           skip-tag: true
332           timeout: 30
333           wipe-workspace: true
334
335 - scm:
336     name: git-extra-project
337     scm:
338       - git:
339           credentials-id: 'onap-jenkins-ssh'
340           url: '$GIT_NO_PROJECT/{project}'
341           refspec: '{refspec}'
342           branches:
343             - 'origin/{branch}'
344           skip-tag: true
345           timeoute: 30
346           wipe-workspace: false
347           basedir: '{checkout-dir}'
348
349 # TRIGGERS
350
351 # This is a single macro to use for all jobs who vote on every (relevant) patch
352 # set. Only 'recheck' trigger word is supported, it always triggers the full set
353 # of relevant jobs, in order to prevent Jenkins from starting only a subset and
354 # still voting Verified+1
355 # Arguments:
356 #     server: name of gerrit server to listen to
357 #     project: pattern to match triggering projects
358 #     branch: triggering branch name
359 #     files: pattern to match triggering filepaths
360 - trigger:
361     name: gerrit-trigger-patch-submitted
362     triggers:
363       - gerrit:
364           server-name: '{server}'
365           trigger-on:
366             - patchset-created-event:
367                 exclude-drafts: 'false'
368                 exclude-trivial-rebase: 'false'
369                 exclude-no-code-change: 'false'
370             - draft-published-event
371             - comment-added-contains-event:
372                 comment-contains-value: 'recheck'
373           projects:
374             - project-compare-type: 'ANT'
375               project-pattern: '{project}'
376               branches:
377                 - branch-compare-type: 'ANT'
378                   branch-pattern: '**/{branch}'
379               file-paths:
380                 - compare-type: 'ANT'
381                   pattern: '{files}'
382
383 - trigger:
384     name: gerrit-trigger-patch-merged
385     triggers:
386       - gerrit:
387           server-name: '{server}'
388           trigger-on:
389             - change-merged-event
390             - comment-added-contains-event:
391                 comment-contains-value: 'remerge'
392           projects:
393             - project-compare-type: 'ANT'
394               project-pattern: '{project}'
395               branches:
396                 - branch-compare-type: 'ANT'
397                   branch-pattern: '**/{branch}'
398               file-paths:
399                 - compare-type: 'ANT'
400                   pattern: '{files}'
401
402 - trigger:
403     name: gerrit-trigger-release-manually
404     triggers:
405       - gerrit:
406           server-name: '{server}'
407           trigger-on:
408             - comment-added-contains-event:
409                 comment-contains-value: 'please release'
410           projects:
411             - project-compare-type: 'ANT'
412               project-pattern: '{project}'
413               branches:
414                 - branch-compare-type: 'ANT'
415                   branch-pattern: '**/{branch}'
416               file-paths:
417                 - compare-type: 'ANT'
418                   pattern: '**'
419
420 - trigger:
421     name: trigger-on-build-success
422     triggers:
423       - reverse:
424           jobs: '{job-name}'
425           result: 'success'
426
427
428 # WRAPPERS
429 - wrapper:
430     name: build-timeout
431     wrappers:
432       - timeout:
433           type: absolute
434           timeout: 360
435           fail: true
436
437 - wrapper:
438     name: golang
439     wrappers:
440       - raw:
441           xml: |
442             <org.jenkinsci.plugins.golang.GolangBuildWrapper plugin="golang@1.2">
443             <goVersion>Golang 1.10</goVersion>
444             </org.jenkinsci.plugins.golang.GolangBuildWrapper>
445
446 - wrapper:
447     # This wrapper is required for all jobs as it configures the wrappers
448     # needed by the eCOMP infra.
449     name: infra-wrappers
450     wrappers:
451       - timestamps
452       - timeout:
453           type: absolute
454           timeout: '{build-timeout}'
455           timeout-var: 'BUILD_TIMEOUT'
456           fail: true
457       - ssh-agent-credentials:
458           users:
459             - 'onap-jenkins-ssh'
460       - openstack:
461           single-use: true