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