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