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