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