global-macros: Enabling timestamps for output logs
[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 # PROPERTIES
113 - property:
114     name: infra-properties
115     properties:
116       - build-discarder:
117           days-to-keep: '{build-days-to-keep}'
118           num-to-keep: 40
119           artifact-days-to-keep: -1
120           artifact-num-to-keep: 5
121
122 # PUBLISHERS
123 - publisher:
124     name: archive-artifacts
125     publishers:
126       - archive:
127           artifacts: '{artifacts}'
128           allow-empty: true
129           fingerprint: true
130           latest-only: true
131
132 - publisher:
133     name: email-notification
134     publishers:
135       - email-ext:
136           recipients: 'nobody@open-o.org'
137           reply-to:
138           content-type: default
139           # yamllint disable rule:line-length
140           subject: '{email-prefix} $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!'
141           # yamllint enable
142           body: |
143             $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS:
144
145             Check console output at $BUILD_URL to view the results.
146           unstable: true
147           fixed: true
148           send-to:
149             - developers
150             - recipients
151
152 - publisher:
153     name: jacoco-report
154     publishers:
155       - jacoco:
156           exec-pattern: '**/**.exec'
157           class-pattern: '**/classes'
158           source-pattern: '**/src/main/java'
159           # yamllint disable rule:line-length
160           exclusion-pattern: '**/gen**,**/generated-sources/**,**/yang-gen**,**/pax/**'
161           # yamllint enable
162           status-update: true
163           targets:
164             - branch:
165                 healthy: 10
166                 unhealthy: 20
167             - method:
168                 healthy: 50
169                 unhealthy: 40
170
171 - publisher:
172     name: infra-shiplogs
173     # To archive things, the job will need to create an "archives" directory in
174     # the workspace and this macro will handle copying the contents of the
175     # archives directory.
176     #
177     # Uses the build parameter ARCHIVE_ARTIFACTS if not empty to find files to
178     # archive. You can pass globstar patterns for example "**/*.xml **/*.log" as
179     # the archive pattern. This is a space separated list of files to archive.
180     #
181     # Also ensure that the workspace is cleaned up at the end of the build.
182     publishers:
183       - postbuildscript:
184           builders:
185             - shell: !include-raw-escape: include-raw-deploy-archives.sh
186             - maven-target:
187                 maven-version: '{maven-version}'
188                 pom: '.archives/deploy-archives.xml'
189                 goals: 'clean deploy -V -B -q -Dmaven.repo.local=/tmp/r'
190                 settings: 'jenkins-log-archives-settings'
191                 settings-type: cfp
192                 global-settings: 'global-settings'
193                 global-settings-type: cfp
194             - description-setter:
195                 regexp: '^Build logs: .*'
196           script-only-if-succeeded: false
197           script-only-if-failed: false
198           mark-unstable-if-failed: true
199       - workspace-cleanup:
200           fail-build: false`
201
202 # SCMS
203 - scm:
204     name: git-scm
205     scm:
206       - git:
207           credentials-id: 'onap-jenkins-ssh'
208           url: '$GIT_BASE'
209           refspec: ''
210           branches:
211             - 'origin/{branch}'
212           skip-tag: true
213           wipe-workspace: true
214           timeout: 30
215
216 - scm:
217     name: gerrit-trigger-scm
218     scm:
219       - git:
220           credentials-id: 'onap-jenkins-ssh'
221           url: '$GIT_BASE'
222           refspec: '{refspec}'
223           branches:
224             - 'origin/$GERRIT_BRANCH'
225           skip-tag: true
226           timeout: 30
227           choosing-strategy: '{choosing-strategy}'
228
229 - scm:
230     name: gerrit-trigger-scm-basedir
231     scm:
232       - git:
233           credentials-id: 'onap-jenkins-ssh'
234           url: '$GIT_BASE'
235           refspec: '{refspec}'
236           branches:
237             - 'origin/$GERRIT_BRANCH'
238           skip-tag: true
239           timeout: 30
240           choosing-strategy: '{choosing-strategy}'
241           basedir: '{basedir}'
242
243 - scm:
244     name: git-branch-scm
245     scm:
246       - git:
247           credentials-id: 'onap-jenkins-ssh'
248           url: '$GIT_BASE'
249           refspec: ''
250           branches:
251             - 'origin/{branch}'
252           skip-tag: true
253           timeout: 30
254           wipe-workspace: true
255
256 - scm:
257     name: git-extra-project
258     scm:
259       - git:
260           credentials-id: 'onap-jenkins-ssh'
261           url: '$GIT_NO_PROJECT/{project}'
262           refspec: '{refspec}'
263           branches:
264             - 'origin/{branch}'
265           skip-tag: true
266           timeoute: 30
267           wipe-workspace: false
268           basedir: '{checkout-dir}'
269
270 # TRIGGERS
271
272 # This is a single macro to use for all jobs who vote on every (relevant) patch
273 # set. Only 'recheck' trigger word is supported, it always triggers the full set
274 # of relevant jobs, in order to prevent Jenkins from starting only a subset and
275 # still voting Verified+1
276 # Arguments:
277 #     server: name of gerrit server to listen to
278 #     project: pattern to match triggering projects
279 #     branch: triggering branch name
280 #     files: pattern to match triggering filepaths
281 - trigger:
282     name: gerrit-trigger-patch-submitted
283     triggers:
284       - gerrit:
285           server-name: '{server}'
286           trigger-on:
287             - patchset-created-event:
288                 exclude-drafts: 'false'
289                 exclude-trivial-rebase: 'false'
290                 exclude-no-code-change: 'false'
291             - draft-published-event
292             - comment-added-contains-event:
293                 comment-contains-value: 'recheck'
294           projects:
295             - project-compare-type: 'ANT'
296               project-pattern: '{project}'
297               branches:
298                 - branch-compare-type: 'ANT'
299                   branch-pattern: '**/{branch}'
300               file-paths:
301                 - compare-type: 'ANT'
302                   pattern: '{files}'
303
304 - trigger:
305     name: gerrit-trigger-patch-merged
306     triggers:
307       - gerrit:
308           server-name: '{server}'
309           trigger-on:
310             - change-merged-event
311             - comment-added-contains-event:
312                 comment-contains-value: 'remerge'
313           projects:
314             - project-compare-type: 'ANT'
315               project-pattern: '{project}'
316               branches:
317                 - branch-compare-type: 'ANT'
318                   branch-pattern: '**/{branch}'
319               file-paths:
320                 - compare-type: 'ANT'
321                   pattern: '{files}'
322
323 - trigger:
324     name: gerrit-trigger-release-manually
325     triggers:
326       - gerrit:
327           server-name: '{server}'
328           trigger-on:
329             - comment-added-contains-event:
330                 comment-contains-value: 'please release'
331           projects:
332             - project-compare-type: 'ANT'
333               project-pattern: '{project}'
334               branches:
335                 - branch-compare-type: 'ANT'
336                   branch-pattern: '**/{branch}'
337               file-paths:
338                 - compare-type: 'ANT'
339                   pattern: '**'
340
341 - trigger:
342     name: trigger-on-build-success
343     triggers:
344       - reverse:
345           jobs: '{job-name}'
346           result: 'success'
347
348
349 # WRAPPERS
350 - wrapper:
351     name: build-timeout
352     wrappers:
353       - timeout:
354           type: absolute
355           timeout: 360
356           fail: true
357
358 - wrapper:
359     # This wrapper is required for all jobs as it configures the wrappers
360     # needed by the eCOMP infra.
361     name: infra-wrappers
362     wrappers:
363       - timestamps
364       - timeout:
365           type: absolute
366           timeout: '{build-timeout}'
367           timeout-var: 'BUILD_TIMEOUT'
368           fail: true
369       - ssh-agent-credentials:
370           users:
371             - 'onap-jenkins-ssh'
372       - openstack:
373           single-use: true