Merge "Migrate gerrit push change to generic builder"
[releng/builder.git] / jjb / releng-macros.yaml
1 # OLD Releng macros
2 ---
3 - property:
4     name: opendaylight-infra-properties
5     properties:
6       - build-discarder:
7           days-to-keep: '{build-days-to-keep}'
8           num-to-keep: 40
9           # Need to keep artifacts for at least 1 day as some projects need to
10           # be able to validate their artifacts and only allowing limited
11           # number of artifacts could make fast moving jobs lost their
12           # artifacts before the developers can test it.
13           artifact-days-to-keep: 1
14
15 - parameter:
16     name: opendaylight-infra-parameters
17     parameters:
18       - string:
19           name: PROJECT
20           default: '{project}'
21           description: 'Parameter to identify an ODL Gerrit project'
22       - string:
23           name: ARCHIVE_ARTIFACTS
24           # Before adding more here, beware of https://jira.linuxfoundation.org/browse/RELENG-280
25           default: >
26               {artifacts}
27               **/target/surefire-reports/*-output.txt
28               **/target/failsafe-reports/failsafe-summary.xml
29               **/hs_err_*.log
30               **/target/feature/feature.xml
31           # TODO: **/*.hprof is too large, compress with xz first
32           description: 'Space separated glob patterns for artifacts to archive into logs.opendaylight.org'
33       - string:
34           name: GERRIT_PROJECT
35           default: '{project}'
36           description: "GERRIT_PROJECT parameter if not given by trigger"
37       - string:
38           name: GERRIT_BRANCH
39           default: '{branch}'
40           description: "JJB configured GERRIT_BRANCH parameter"
41       - string:
42           name: GERRIT_REFSPEC
43           default: '{refspec}'
44           description: |
45               Gerrit reference to checkout (ex: refs/heads/master,
46               refs/changes/48/61548/1 where 61548 is Gerrit change ID, 1 is
47               patch number and 48 is last two digits of change ID)
48       - string:
49           name: STACK_NAME
50           default: '$SILO-$JOB_NAME-$BUILD_NUMBER'
51           description: "Used by Heat to generate a unique stack & vm name"
52       - string:
53           name: OS_CLOUD
54           default: '{os-cloud}'
55           description: |
56               The name of a cloud configuration in clouds.yaml. OS_CLOUD is a
57               variable name that is significant to openstack client as a
58               environment variable. Please refer to the documentation for
59               further details.
60               https://docs.openstack.org/developer/python-openstackclient/
61
62 - parameter:
63     name: build-tag
64     parameters:
65       - string:
66           name: BUILD_TAG
67           default: ''
68           description: 'Tag in Git to checkout'
69
70 - parameter:
71     name: controller-version-parameter
72     parameters:
73       - string:
74           name: ODL_VERSION
75           default: '{odl_version}'
76           description: 'Controller version (for use with openstacks networking_odl project)'
77
78 - parameter:
79     name: patches-to-build-parameter
80     parameters:
81       - string:
82           name: PATCHES_TO_BUILD
83           default: ''
84           description: |
85               Ordered list of patches to build in the format of project=changeset (checkout) or
86               project:changeset (cherry-pick) for example: genius=32/53632/9,netvirt:59/50259/47
87
88 - parameter:
89     name: run-test-parameter
90     parameters:
91       - string:
92           name: RUN_TEST
93           default: '{run-test}'
94           description: 'Set true to run test after build'
95
96 - parameter:
97     name: build-fast-parameter
98     parameters:
99       - string:
100           name: BUILD_FAST
101           default: '{build-fast}'
102           description: 'Set true to build fast -Pq'
103
104 - parameter:
105     name: distribution-branch-to-build-parameter
106     parameters:
107       - string:
108           name: DISTRIBUTION_BRANCH_TO_BUILD
109           default: 'master'
110           description: 'distribution repo branch to build with'
111
112 - parameter:
113     name: p2zip-parameter
114     parameters:
115       - string:
116           name: P2ZIP_URL
117           default: ''
118           description: 'Nexus staging profile id'
119
120 - parameter:
121     name: stage-id-parameter
122     parameters:
123       - string:
124           name: STAGING_PROFILE_ID
125           default: '{stage-id}'
126           description: 'Nexus staging profile id'
127
128 - parameter:
129     name: maven-exec
130     parameters:
131       - string:
132           name: MVN
133           default: '/w/tools/hudson.tasks.Maven_MavenInstallation/{maven-version}/bin/mvn'
134           description: 'Maven selector to be used by shell scripts'
135
136 - scm:
137     name: git-scm
138     scm:
139       - git:
140           credentials-id: 'opendaylight-jenkins-ssh'
141           url: '$GIT_BASE'
142           refspec: ''
143           branches:
144             - 'origin/{branch}'
145           skip-tag: true
146           wipe-workspace: true
147
148 - scm:
149     name: git-scm-with-submodules
150     scm:
151       - git:
152           credentials-id: 'opendaylight-jenkins-ssh'
153           url: '$GIT_BASE'
154           refspec: ''
155           branches:
156             - 'refs/heads/{branch}'
157           skip-tag: true
158           wipe-workspace: true
159           submodule:
160             recursive: true
161
162 - scm:
163     name: gerrit-trigger-scm
164     scm:
165       - git:
166           credentials-id: 'opendaylight-jenkins-ssh'
167           url: '$GIT_BASE'
168           refspec: '{refspec}'
169           branches:
170             - 'origin/$GERRIT_BRANCH'
171           skip-tag: true
172           choosing-strategy: '{choosing-strategy}'
173
174 - wrapper:
175     name: build-timeout
176     wrappers:
177       - timeout:
178           type: absolute
179           timeout: 360
180           fail: true
181
182 # This is a single macro to use for all jobs who vote on every (relevant) patch set.
183 # Only 'recheck' trigger word is supported, it always triggers the full set of relevant jobs,
184 # in order to prevent Jenkins from starting only a subset and still voting Verified+1.
185 # Arguments:
186 #     gerrit-server-name: name of gerrit server to listen to
187 #     project: pattern to match triggering projects
188 #     branch: triggering branch name
189 #     files: pattern to match triggering filepaths
190 - trigger:
191     name: gerrit-trigger-patch-submitted
192     triggers:
193       - gerrit:
194           server-name: '{gerrit-server-name}'
195           trigger-on:
196             - patchset-created-event:
197                 exclude-drafts: true
198                 exclude-trivial-rebase: false
199                 exclude-no-code-change: false
200             - draft-published-event
201             - comment-added-contains-event:
202                 comment-contains-value: 'recheck$'
203           projects:
204             - project-compare-type: ANT
205               project-pattern: '{project}'
206               branches:
207                 - branch-compare-type: ANT
208                   branch-pattern: '**/{branch}'
209               file-paths:
210                 - compare-type: ANT
211                   pattern: '{files}'
212
213 # TODO: Unify argument names across gerrit-trigger-* macros.
214 - trigger:
215     name: gerrit-trigger-patch-merged
216     triggers:
217       - gerrit:
218           server-name: '{gerrit-server-name}'
219           trigger-on:
220             - change-merged-event
221             - comment-added-contains-event:
222                 comment-contains-value: 'remerge$'
223           projects:
224             - project-compare-type: 'ANT'
225               project-pattern: '{name}'
226               branches:
227                 - branch-compare-type: 'ANT'
228                   branch-pattern: '**/{branch}'
229           skip-vote:
230             successful: true
231             failed: true
232             unstable: true
233             notbuilt: true
234           # Force Jenkins always vote the values it should already have voted
235           # during the prior verify phase
236           override-votes: true
237           gerrit-build-started-verified-value: 1
238           gerrit-build-successful-verified-value: 1
239           gerrit-build-failed-verified-value: 1
240           gerrit-build-unstable-verified-value: 1
241           gerrit-build-notbuilt-verified-value: 1
242           gerrit-build-started-codereview-value: 0
243           gerrit-build-successful-codereview-value: 0
244           gerrit-build-failed-codereview-value: 0
245           gerrit-build-unstable-codereview-value: 0
246           gerrit-build-notbuilt-codereview-value: 0
247
248 # TODO: Unify argument names across gerrit-trigger-* macros.
249 - trigger:
250     name: gerrit-trigger-patch-sonar
251     triggers:
252       - gerrit:
253           server-name: '{gerrit-server-name}'
254           trigger-on:
255             - comment-added-contains-event:
256                 comment-contains-value: 'run-sonar'
257           projects:
258             - project-compare-type: 'ANT'
259               project-pattern: '{name}'
260               branches:
261                 - branch-compare-type: 'ANT'
262                   branch-pattern: '**/master'
263           skip-vote:
264             successful: true
265             failed: true
266             unstable: true
267             notbuilt: true
268
269 - publisher:
270     name: email-notification
271     publishers:
272       - email-ext:
273           recipients: '{email-recipients}'
274           reply-to: ''
275           content-type: default
276           subject: '{email-prefix} $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!'
277           body: |
278               $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS:
279
280               Please refer to the logs server URL for console logs when possible
281               and use the Jenkins Build URL as a last resort.
282
283               Console Logs URL:
284               https://logs.opendaylight.org/$SILO/$JENKINS_HOSTNAME/$JOB_NAME/$BUILD_NUMBER
285
286               Jenkins Build URL:
287               $BUILD_URL
288           unstable: true
289           fixed: true
290           send-to:
291             - recipients
292
293
294 - builder:
295     # Installs the openstack cli into a virtualenv at /tmp/v/openstack
296     name: odl-openstack-install
297     builders:
298       - shell: !include-raw: odl-openstack-install.sh
299
300 - builder:
301     name: odl-openstack-check-image-protection
302     builders:
303       - shell: !include-raw: odl-openstack-check-image-protection.sh
304
305 - builder:
306     name: odl-openstack-cleanup-old-images
307     builders:
308       - shell: !include-raw: odl-openstack-cleanup-old-images.sh
309
310 - builder:
311     name: odl-openstack-cleanup-orphaned-nodes
312     builders:
313       - shell: !include-raw: odl-openstack-cleanup-orphaned-nodes.sh
314
315 - builder:
316     name: odl-openstack-cleanup-stale-nodes
317     builders:
318       - shell: !include-raw: odl-openstack-cleanup-stale-nodes.sh
319
320 - builder:
321     name: odl-openstack-cleanup-stale-stacks
322     builders:
323       - shell: !include-raw: odl-openstack-cleanup-stale-stacks.sh
324
325 - builder:
326     name: odl-openstack-cleanup-stale-volumes
327     builders:
328       - shell: !include-raw: odl-openstack-cleanup-stale-volumes.sh
329
330 - builder:
331     # Deploys a maven site to Nexus using lftools nexus-zip command
332     name: opendaylight-infra-deploy-maven-site
333     builders:
334       - lf-provide-maven-settings:
335           global-settings-file: global-settings
336           settings-file: '{settings-file}'
337       - lf-infra-create-netrc:
338           server-id: opendaylight-site
339       - shell: !include-raw-escape:
340           - global-jjb/shell/lftools-install.sh
341           - opendaylight-infra-deploy-maven-site.sh
342       - lf-provide-maven-settings-cleanup
343
344 - builder:
345     name: opendaylight-infra-stack
346     # opendaylight-infra-stack.sh has a required variable {stack-template} that
347     # must be passed into this macro.
348     builders:
349       - shell: !include-raw: opendaylight-infra-stack.sh
350       - shell: !include-raw-escape: opendaylight-infra-copy-ssh-keys.sh
351
352 - builder:
353     name: distribute-build-url
354     # Place URL of the current run of a build job to a file at given path.
355     builders:
356       - shell: |
357           #!/bin/bash
358           set +e  # DO NOT fail script if command returns non-zero.
359
360           echo "$BUILD_URL" > {path}/build.url
361
362           # DO NOT fail the build if the echo failed.
363           exit 0
364
365 - builder:
366     name: wipe-org-opendaylight-repo
367     builders:
368       - shell: 'if [ -d /tmp/r/org/opendaylight ]; then rm -rf /tmp/r/org/opendaylight; fi'
369
370 - builder:
371     name: wipe-local-maven-repo
372     builders:
373       - shell: 'if [ -d /tmp/r ]; then rm -rf /tmp/r; fi'
374
375 - builder:
376     name: jacoco-nojava-workaround
377     builders:
378       - shell: 'mkdir -p $WORKSPACE/target/classes $WORKSPACE/jacoco/classes'
379
380 - builder:
381     name: check-clm
382     builders:
383       - sonatype-clm:
384           application-name: '{application-name}'
385
386 - builder:
387     name: releng-check-unicode
388     builders:
389       - shell: |
390           $WORKSPACE/scripts/check-unicode.sh jjb/
391
392 - builder:
393     name: provide-maven-settings
394     builders:
395       - config-file-provider:
396           files:
397             - file-id: '{global-settings-file}'
398               variable: 'GLOBAL_SETTINGS_FILE'
399             - file-id: '{settings-file}'
400               variable: 'SETTINGS_FILE'
401
402 - builder:
403     name: releng-fetch-p2zip-if-necessary
404     builders:
405       - shell: |
406           # Cleanup any existing zips and metadata before we download the new update site
407           rm -f *.zip *.xml
408       - conditional-step:
409           condition-kind: strings-match
410           condition-string1: '$P2ZIP_URL'
411           condition-string2: ''
412           condition-basedir: workspace
413           steps:
414             # TODO: Figure out latest snapshot version number to pull rather than hardcoding 1.1.1-SNAPSHOT
415             - maven-target:
416                 maven-version: '{maven-version}'
417                 goals: >
418                     org.apache.maven.plugins:maven-dependency-plugin:get
419                     org.apache.maven.plugins:maven-dependency-plugin:copy
420                     -V -B
421                     -Dartifact=org.opendaylight.yangide:org.opendaylight.yangide.update-site:1.1.1-SNAPSHOT:zip
422                     -DoutputDirectory=$WORKSPACE
423                 settings: '{settings}'
424                 global-settings: '{global-settings}'
425
426 - builder:
427     name: releng-generate-p2pom
428     builders:
429       - shell: !include-raw: generate-p2pom.sh
430
431 - builder:
432     name: releng-update-p2composite-metadata
433     builders:
434       - shell: !include-raw: update-p2composite-metadata.sh
435       - conditional-step:
436           condition-kind: file-exists
437           condition-filename: deploy-composite-repo.xml
438           condition-basedir: workspace
439           steps:
440             - maven-target:
441                 maven-version: '{maven-version}'
442                 pom: 'deploy-composite-repo.xml'
443                 goals: 'clean deploy -V -B -Dmaven.repo.local=/tmp/r'
444                 settings: '{settings}'
445                 global-settings: '{global-settings}'
446
447 - publisher:
448     name: releng-openstack-stack-delete
449     publishers:
450       - postbuildscript:
451           builders:
452             - role: BOTH
453               build-on:
454                 - ABORTED
455                 - FAILURE
456                 - SUCCESS
457                 - UNSTABLE
458               build-steps:
459                 - shell: |
460                     #!/bin/bash
461                     echo "Deleting $STACK_NAME"
462                     source "/tmp/v/openstack/bin/activate"
463                     openstack stack delete --yes "$STACK_NAME"
464           mark-unstable-if-failed: false
465
466 - builder:
467     name: releng-stage-release
468     builders:
469       - shell: !include-raw: stage-release.sh
470
471 - wrapper:
472     # This wrapper is required for all jobs as it configures the wrappers
473     # needed by OpenDaylight infra.
474     name: opendaylight-infra-wrappers
475     wrappers:
476       - mask-passwords
477       - config-file-provider:
478           files:
479             - file-id: npmrc
480               target: '$HOME/.npmrc'
481             - file-id: pipconf
482               target: '$HOME/.config/pip/pip.conf'
483             - file-id: clouds-yaml
484               target: '$HOME/.config/openstack/clouds.yaml'
485       - timeout:
486           type: absolute
487           timeout: '{build-timeout}'
488           timeout-var: 'BUILD_TIMEOUT'
489           fail: true
490       - timestamps
491       - ssh-agent-credentials:
492           users:
493             - 'opendaylight-jenkins-ssh'
494       - openstack:
495           single-use: true
496
497 - publisher:
498     name: opendaylight-infra-generate-csit-status-report
499     publishers:
500       - postbuildscript:
501           builders:
502             - role: BOTH
503               build-on:
504                 - ABORTED
505                 - FAILURE
506                 - NOT_BUILT
507                 - SUCCESS
508                 - UNSTABLE
509               build-steps:
510                 - shell: !include-raw: generate-csit-status-report.sh
511           mark-unstable-if-failed: true