Upgrade to global-jjb v0.17.0
[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: docker-login
66     builders:
67       - shell: !include-raw: include-docker-login.sh
68
69 - builder:
70     name: publish-pypi
71     builders:
72       - inject:
73           properties-content: PYPI_SERVER={pypi-server}
74       - shell:
75           !include-raw-escape: ../shell/pypi-publish.sh
76
77 # PARAMETERS
78 - parameter:
79     name: infra-parameters
80     parameters:
81       - string:
82           name: PROJECT
83           default: '{project}'
84           # yamllint disable rule:line-length
85           description: 'JJB configured PROJECT parameter to identify a Gerrit project'
86           # yamllint enable
87       - string:
88           name: ARCHIVE_ARTIFACTS
89           default: '{artifacts} **/target/surefire-reports/*-output.txt'
90           # yamllint disable rule:line-length
91           description: 'Space separated glob patterns for artifacts to archive to logs hosting'
92           # yamllint enable
93       - string:
94           name: GERRIT_BRANCH
95           default: '{branch}'
96           description: 'JJB configured GERRIT_BRANCH parameter'
97       - string:
98           name: GERRIT_PROJECT
99           default: '{project}'
100           description: 'GERRIT_PROJECT parameter if not given by trigger'
101       - string:
102           name: GERRIT_REFSPEC
103           default: '{refspec}'
104           description: 'GERRIT_REFSPEC parameter if not given by trigger'
105       - string:
106           name: STACK_NAME
107           default: '$JOB_NAME-$BUILD_NUMBER'
108           description: 'Used by Heat to generate a unique stack & vm name'
109
110 - parameter:
111     name: maven-exec
112     parameters:
113       - string:
114           name: MVN
115           # yamllint disable rule:line-length
116           default: '/w/tools/hudson.tasks.Maven_MavenInstallation/{maven-version}/bin/mvn'
117           # yamllint enable
118           description: 'Maven selector to be used by shell scripts'
119
120 - parameter:
121     name: docker-image-name
122     parameters:
123       - string:
124           name: DOCKER_IMAGE_NAME
125           # yamllint disable rule:line-length
126           default: '{docker-image-name}'
127           # yamllint enable
128           description: 'Docker image name, e.g. onap/appc'
129
130 # PROPERTIES
131 - property:
132     name: infra-properties
133     properties:
134       - build-discarder:
135           days-to-keep: '{build-days-to-keep}'
136           num-to-keep: 40
137           artifact-days-to-keep: -1
138           artifact-num-to-keep: 5
139
140 # PUBLISHERS
141 - publisher:
142     name: archive-artifacts
143     publishers:
144       - archive:
145           artifacts: '{artifacts}'
146           allow-empty: true
147           fingerprint: true
148           latest-only: true
149
150 - publisher:
151     name: email-notification
152     publishers:
153       - email-ext:
154           recipients: 'nobody@open-o.org'
155           reply-to:
156           content-type: default
157           # yamllint disable rule:line-length
158           subject: '{email-prefix} $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!'
159           # yamllint enable
160           body: |
161             $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS:
162
163             Check console output at $BUILD_URL to view the results.
164           unstable: true
165           fixed: true
166           send-to:
167             - developers
168             - recipients
169
170 - publisher:
171     name: jacoco-report
172     publishers:
173       - jacoco:
174           exec-pattern: '**/**.exec'
175           class-pattern: '**/classes'
176           source-pattern: '**/src/main/java'
177           # yamllint disable rule:line-length
178           exclusion-pattern: '**/gen**,**/generated-sources/**,**/yang-gen**,**/pax/**'
179           # yamllint enable
180           status-update: true
181           targets:
182             - branch:
183                 healthy: 10
184                 unhealthy: 20
185             - method:
186                 healthy: 50
187                 unhealthy: 40
188
189 - publisher:
190     name: checkstyle-result
191     publishers:
192       - checkstyle:
193           pattern: '**/checkstyle-result.xml'
194           healthy: 0
195           unhealthy: 100
196           health-threshold: 'high'
197           thresholds:
198             unstable:
199               total-all: 30
200               total-high: 15
201               total-normal: 20
202               total-low: 25
203               new-all: 5
204               new-high: 0
205               new-normal: 2
206               new-low: 5
207
208 - publisher:
209     name: checkstyle-result-daily
210     publishers:
211       - checkstyle:
212           pattern: '**/checkstyle-result.xml'
213           healthy: 0
214           unhealthy: 100
215           health-threshold: 'high'
216           thresholds:
217             unstable:
218               total-all: 30
219               total-high: 15
220               total-normal: 20
221               total-low: 25
222               new-all: 1
223               new-high: 0
224               new-normal: 1
225               new-low: 1
226
227 - publisher:
228     name: infra-shiplogs
229     # To archive things, the job will need to create an "archives" directory in
230     # the workspace and this macro will handle copying the contents of the
231     # archives directory.
232     #
233     # Uses the build parameter ARCHIVE_ARTIFACTS if not empty to find files to
234     # archive. You can pass globstar patterns for example "**/*.xml **/*.log" as
235     # the archive pattern. This is a space separated list of files to archive.
236     #
237     # Also ensure that the workspace is cleaned up at the end of the build.
238     publishers:
239       - postbuildscript:
240           builders:
241             - shell: !include-raw-escape: include-raw-deploy-archives.sh
242             - maven-target:
243                 maven-version: '{maven-version}'
244                 pom: '.archives/deploy-archives.xml'
245                 goals: 'clean deploy -V -B -q -Dmaven.repo.local=/tmp/r'
246                 settings: 'jenkins-log-archives-settings'
247                 settings-type: cfp
248                 global-settings: 'global-settings'
249                 global-settings-type: cfp
250             - description-setter:
251                 regexp: '^Build logs: .*'
252           script-only-if-succeeded: false
253           script-only-if-failed: false
254           mark-unstable-if-failed: true
255       - workspace-cleanup:
256           fail-build: false`
257
258 # SCMS
259 - scm:
260     name: git-scm
261     scm:
262       - git:
263           credentials-id: 'onap-jenkins-ssh'
264           url: '$GIT_BASE'
265           refspec: ''
266           branches:
267             - 'origin/{branch}'
268           skip-tag: true
269           wipe-workspace: true
270           timeout: 30
271
272 - scm:
273     name: gerrit-trigger-scm
274     scm:
275       - git:
276           credentials-id: 'onap-jenkins-ssh'
277           url: '$GIT_BASE'
278           refspec: '{refspec}'
279           branches:
280             - 'origin/$GERRIT_BRANCH'
281           skip-tag: true
282           timeout: 30
283           choosing-strategy: '{choosing-strategy}'
284           submodule:
285             recursive: '{submodule-recursive}'
286
287 - scm:
288     name: gerrit-trigger-scm-basedir
289     scm:
290       - git:
291           credentials-id: 'onap-jenkins-ssh'
292           url: '$GIT_BASE'
293           refspec: '{refspec}'
294           branches:
295             - 'origin/$GERRIT_BRANCH'
296           skip-tag: true
297           timeout: 30
298           choosing-strategy: '{choosing-strategy}'
299           basedir: '{basedir}'
300
301 - scm:
302     name: git-branch-scm
303     scm:
304       - git:
305           credentials-id: 'onap-jenkins-ssh'
306           url: '$GIT_BASE'
307           refspec: ''
308           branches:
309             - 'origin/{branch}'
310           skip-tag: true
311           timeout: 30
312           wipe-workspace: true
313
314 - scm:
315     name: git-extra-project
316     scm:
317       - git:
318           credentials-id: 'onap-jenkins-ssh'
319           url: '$GIT_NO_PROJECT/{project}'
320           refspec: '{refspec}'
321           branches:
322             - 'origin/{branch}'
323           skip-tag: true
324           timeoute: 30
325           wipe-workspace: false
326           basedir: '{checkout-dir}'
327
328 # TRIGGERS
329
330 # This is a single macro to use for all jobs who vote on every (relevant) patch
331 # set. Only 'recheck' trigger word is supported, it always triggers the full set
332 # of relevant jobs, in order to prevent Jenkins from starting only a subset and
333 # still voting Verified+1
334 # Arguments:
335 #     server: name of gerrit server to listen to
336 #     project: pattern to match triggering projects
337 #     branch: triggering branch name
338 #     files: pattern to match triggering filepaths
339 - trigger:
340     name: gerrit-trigger-patch-submitted
341     triggers:
342       - gerrit:
343           server-name: '{server}'
344           trigger-on:
345             - patchset-created-event:
346                 exclude-drafts: 'false'
347                 exclude-trivial-rebase: 'false'
348                 exclude-no-code-change: 'false'
349             - draft-published-event
350             - comment-added-contains-event:
351                 comment-contains-value: 'recheck'
352           projects:
353             - project-compare-type: 'ANT'
354               project-pattern: '{project}'
355               branches:
356                 - branch-compare-type: 'ANT'
357                   branch-pattern: '**/{branch}'
358               file-paths:
359                 - compare-type: 'ANT'
360                   pattern: '{files}'
361
362 - trigger:
363     name: gerrit-trigger-patch-merged
364     triggers:
365       - gerrit:
366           server-name: '{server}'
367           trigger-on:
368             - change-merged-event
369             - comment-added-contains-event:
370                 comment-contains-value: 'remerge'
371           projects:
372             - project-compare-type: 'ANT'
373               project-pattern: '{project}'
374               branches:
375                 - branch-compare-type: 'ANT'
376                   branch-pattern: '**/{branch}'
377               file-paths:
378                 - compare-type: 'ANT'
379                   pattern: '{files}'
380
381 - trigger:
382     name: gerrit-trigger-release-manually
383     triggers:
384       - gerrit:
385           server-name: '{server}'
386           trigger-on:
387             - comment-added-contains-event:
388                 comment-contains-value: 'please release'
389           projects:
390             - project-compare-type: 'ANT'
391               project-pattern: '{project}'
392               branches:
393                 - branch-compare-type: 'ANT'
394                   branch-pattern: '**/{branch}'
395               file-paths:
396                 - compare-type: 'ANT'
397                   pattern: '**'
398
399 - trigger:
400     name: trigger-on-build-success
401     triggers:
402       - reverse:
403           jobs: '{job-name}'
404           result: 'success'
405
406
407 # WRAPPERS
408 - wrapper:
409     name: build-timeout
410     wrappers:
411       - timeout:
412           type: absolute
413           timeout: 360
414           fail: true
415
416 - wrapper:
417     # This wrapper is required for all jobs as it configures the wrappers
418     # needed by the eCOMP infra.
419     name: infra-wrappers
420     wrappers:
421       - timestamps
422       - timeout:
423           type: absolute
424           timeout: '{build-timeout}'
425           timeout-var: 'BUILD_TIMEOUT'
426           fail: true
427       - ssh-agent-credentials:
428           users:
429             - 'onap-jenkins-ssh'
430       - openstack:
431           single-use: true