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