a9564f5a489c765c961045e991751698749e33b3
[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: RUNTEST
93           default: '{run-test}'
94           description: 'Set true to run test after build'
95
96 - parameter:
97     name: distribution-branch-to-build-parameter
98     parameters:
99       - string:
100           name: DISTRIBUTION_BRANCH_TO_BUILD
101           default: 'master'
102           description: 'distribution repo branch to build with'
103
104 - parameter:
105     name: p2zip-parameter
106     parameters:
107       - string:
108           name: P2ZIP_URL
109           default: ''
110           description: 'Nexus staging profile id'
111
112 - parameter:
113     name: stage-id-parameter
114     parameters:
115       - string:
116           name: STAGING_PROFILE_ID
117           default: '{stage-id}'
118           description: 'Nexus staging profile id'
119
120 - parameter:
121     name: maven-exec
122     parameters:
123       - string:
124           name: MVN
125           default: '/w/tools/hudson.tasks.Maven_MavenInstallation/{maven-version}/bin/mvn'
126           description: 'Maven selector to be used by shell scripts'
127
128 - scm:
129     name: git-scm
130     scm:
131       - git:
132           credentials-id: 'opendaylight-jenkins-ssh'
133           url: '$GIT_BASE'
134           refspec: ''
135           branches:
136             - 'origin/{branch}'
137           skip-tag: true
138           wipe-workspace: true
139
140 - scm:
141     name: git-scm-with-submodules
142     scm:
143       - git:
144           credentials-id: 'opendaylight-jenkins-ssh'
145           url: '$GIT_BASE'
146           refspec: ''
147           branches:
148             - 'refs/heads/{branch}'
149           skip-tag: true
150           wipe-workspace: true
151           submodule:
152             recursive: true
153
154 - scm:
155     name: gerrit-trigger-scm
156     scm:
157       - git:
158           credentials-id: 'opendaylight-jenkins-ssh'
159           url: '$GIT_BASE'
160           refspec: '{refspec}'
161           branches:
162             - 'origin/$GERRIT_BRANCH'
163           skip-tag: true
164           choosing-strategy: '{choosing-strategy}'
165
166 - wrapper:
167     name: build-timeout
168     wrappers:
169       - timeout:
170           type: absolute
171           timeout: 360
172           fail: true
173
174 # This is a single macro to use for all jobs who vote on every (relevant) patch set.
175 # Only 'recheck' trigger word is supported, it always triggers the full set of relevant jobs,
176 # in order to prevent Jenkins from starting only a subset and still voting Verified+1.
177 # Arguments:
178 #     gerrit-server-name: name of gerrit server to listen to
179 #     project: pattern to match triggering projects
180 #     branch: triggering branch name
181 #     files: pattern to match triggering filepaths
182 - trigger:
183     name: gerrit-trigger-patch-submitted
184     triggers:
185       - gerrit:
186           server-name: '{gerrit-server-name}'
187           trigger-on:
188             - patchset-created-event:
189                 exclude-drafts: true
190                 exclude-trivial-rebase: false
191                 exclude-no-code-change: false
192             - draft-published-event
193             - comment-added-contains-event:
194                 comment-contains-value: recheck
195           projects:
196             - project-compare-type: ANT
197               project-pattern: '{project}'
198               branches:
199                 - branch-compare-type: ANT
200                   branch-pattern: '**/{branch}'
201               file-paths:
202                 - compare-type: ANT
203                   pattern: '{files}'
204
205 # TODO: Unify argument names across gerrit-trigger-* macros.
206 - trigger:
207     name: gerrit-trigger-patch-merged
208     triggers:
209       - gerrit:
210           server-name: '{gerrit-server-name}'
211           trigger-on:
212             - change-merged-event
213             - comment-added-contains-event:
214                 comment-contains-value: 'remerge'
215           projects:
216             - project-compare-type: 'ANT'
217               project-pattern: '{name}'
218               branches:
219                 - branch-compare-type: 'ANT'
220                   branch-pattern: '**/{branch}'
221           skip-vote:
222             successful: true
223             failed: true
224             unstable: true
225             notbuilt: true
226           # Force Jenkins always vote the values it should already have voted
227           # during the prior verify phase
228           override-votes: true
229           gerrit-build-started-verified-value: 1
230           gerrit-build-successful-verified-value: 1
231           gerrit-build-failed-verified-value: 1
232           gerrit-build-unstable-verified-value: 1
233           gerrit-build-notbuilt-verified-value: 1
234           gerrit-build-started-codereview-value: 0
235           gerrit-build-successful-codereview-value: 0
236           gerrit-build-failed-codereview-value: 0
237           gerrit-build-unstable-codereview-value: 0
238           gerrit-build-notbuilt-codereview-value: 0
239
240 # TODO: Unify argument names across gerrit-trigger-* macros.
241 - trigger:
242     name: gerrit-trigger-patch-sonar
243     triggers:
244       - gerrit:
245           server-name: '{gerrit-server-name}'
246           trigger-on:
247             - comment-added-contains-event:
248                 comment-contains-value: 'run-sonar'
249           projects:
250             - project-compare-type: 'ANT'
251               project-pattern: '{name}'
252               branches:
253                 - branch-compare-type: 'ANT'
254                   branch-pattern: '**/master'
255           skip-vote:
256             successful: true
257             failed: true
258             unstable: true
259             notbuilt: true
260
261 - publisher:
262     name: email-notification
263     publishers:
264       - email-ext:
265           recipients: '{email-recipients}'
266           reply-to: ''
267           content-type: default
268           subject: '{email-prefix} $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!'
269           body: |
270               $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS:
271
272               Please refer to the logs server URL for console logs when possible
273               and use the Jenkins Build URL as a last resort.
274
275               Console Logs URL:
276               https://logs.opendaylight.org/$SILO/$JENKINS_HOSTNAME/$JOB_NAME/$BUILD_NUMBER
277
278               Jenkins Build URL:
279               $BUILD_URL
280           unstable: true
281           fixed: true
282           send-to:
283             - recipients
284
285
286 - builder:
287     # Installs the openstack cli into a virtualenv at /tmp/v/openstack
288     name: odl-openstack-install
289     builders:
290       - shell: !include-raw: odl-openstack-install.sh
291
292 - builder:
293     name: odl-openstack-check-image-protection
294     builders:
295       - shell: !include-raw: odl-openstack-check-image-protection.sh
296
297 - builder:
298     # Deploys a maven site to Nexus using lftools nexus-zip command
299     name: opendaylight-infra-deploy-maven-site
300     builders:
301       - lf-provide-maven-settings:
302           global-settings-file: global-settings
303           settings-file: '{settings-file}'
304       - lf-infra-create-netrc:
305           server-id: opendaylight-site
306       - shell: !include-raw-escape:
307           - global-jjb/shell/lftools-install.sh
308           - opendaylight-infra-deploy-maven-site.sh
309       - lf-provide-maven-settings-cleanup
310
311 - builder:
312     name: opendaylight-infra-stack
313     # opendaylight-infra-stack.sh has a required variable {stack-template} that
314     # must be passed into this macro.
315     builders:
316       - shell: !include-raw: opendaylight-infra-stack.sh
317       - shell: !include-raw-escape: opendaylight-infra-copy-ssh-keys.sh
318
319 - builder:
320     name: opendaylight-infra-push-gerrit-patch
321     # opendaylight-infra-push-gerrit-patch.sh allows a job to push a patch to
322     # Gerrit in an automated fashion. This is meant for tasks that creates
323     # the same patch regularly and needs the ability to detect if an unreviewed
324     # patch already exists. In which case it will update the existing patch.
325     #
326     # Note: This patch assumes the $WORKSPACE contains the project repo with
327     #       the files changed already "git add" and waiting for a "git commit" call.
328     #
329     # This script requires the following JJB variables to be passed in:
330     #     {project}       Gerrit project-name
331     #     {gerrit-topic}  Gerrit topic, please make a unique topic.
332     #     {gerrit-commit-message} Commit message to assign to commit.
333     # NOTE: Requires git review to be installed on node.
334     builders:
335       - shell: !include-raw: opendaylight-infra-push-gerrit-patch.sh
336
337 - builder:
338     name: distribute-build-url
339     # Place URL of the current run of a build job to a file at given path.
340     builders:
341       - shell: |
342           #!/bin/bash
343           set +e  # DO NOT fail script if command returns non-zero.
344
345           echo "$BUILD_URL" > {path}/build.url
346
347           # DO NOT fail the build if the echo failed.
348           exit 0
349
350 - builder:
351     name: wipe-org-opendaylight-repo
352     builders:
353       - shell: 'if [ -d /tmp/r/org/opendaylight ]; then rm -rf /tmp/r/org/opendaylight; fi'
354
355 - builder:
356     name: wipe-local-maven-repo
357     builders:
358       - shell: 'if [ -d /tmp/r ]; then rm -rf /tmp/r; fi'
359
360 - builder:
361     name: jacoco-nojava-workaround
362     builders:
363       - shell: 'mkdir -p $WORKSPACE/target/classes $WORKSPACE/jacoco/classes'
364
365 - builder:
366     name: check-clm
367     builders:
368       - sonatype-clm:
369           application-name: '{application-name}'
370
371 - builder:
372     name: releng-check-unicode
373     builders:
374       - shell: |
375           $WORKSPACE/scripts/check-unicode.sh jjb/
376
377 - builder:
378     name: provide-maven-settings
379     builders:
380       - config-file-provider:
381           files:
382             - file-id: '{global-settings-file}'
383               variable: 'GLOBAL_SETTINGS_FILE'
384             - file-id: '{settings-file}'
385               variable: 'SETTINGS_FILE'
386
387 - builder:
388     name: releng-fetch-p2zip-if-necessary
389     builders:
390       - shell: |
391           # Cleanup any existing zips and metadata before we download the new update site
392           rm -f *.zip *.xml
393       - conditional-step:
394           condition-kind: strings-match
395           condition-string1: '$P2ZIP_URL'
396           condition-string2: ''
397           condition-basedir: workspace
398           steps:
399             # TODO: Figure out latest snapshot version number to pull rather than hardcoding 1.1.1-SNAPSHOT
400             - maven-target:
401                 maven-version: '{maven-version}'
402                 goals: >
403                     org.apache.maven.plugins:maven-dependency-plugin:get
404                     org.apache.maven.plugins:maven-dependency-plugin:copy
405                     -V -B
406                     -Dartifact=org.opendaylight.yangide:org.opendaylight.yangide.update-site:1.1.1-SNAPSHOT:zip
407                     -DoutputDirectory=$WORKSPACE
408                 settings: '{settings}'
409                 global-settings: '{global-settings}'
410
411 - builder:
412     name: releng-generate-p2pom
413     builders:
414       - shell: !include-raw: generate-p2pom.sh
415
416 - builder:
417     name: releng-update-p2composite-metadata
418     builders:
419       - shell: !include-raw: update-p2composite-metadata.sh
420       - conditional-step:
421           condition-kind: file-exists
422           condition-filename: deploy-composite-repo.xml
423           condition-basedir: workspace
424           steps:
425             - maven-target:
426                 maven-version: '{maven-version}'
427                 pom: 'deploy-composite-repo.xml'
428                 goals: 'clean deploy -V -B -Dmaven.repo.local=/tmp/r'
429                 settings: '{settings}'
430                 global-settings: '{global-settings}'
431
432 - builder:
433     name: releng-stage-release
434     builders:
435       - shell: !include-raw: stage-release.sh
436
437 - wrapper:
438     # This wrapper is required for all jobs as it configures the wrappers
439     # needed by OpenDaylight infra.
440     name: opendaylight-infra-wrappers
441     wrappers:
442       - mask-passwords
443       - config-file-provider:
444           files:
445             - file-id: npmrc
446               target: '$HOME/.npmrc'
447             - file-id: clouds-yaml
448               target: '$HOME/.config/openstack/clouds.yaml'
449       - timeout:
450           type: absolute
451           timeout: '{build-timeout}'
452           timeout-var: 'BUILD_TIMEOUT'
453           fail: true
454       - timestamps
455       - ssh-agent-credentials:
456           users:
457             - 'opendaylight-jenkins-ssh'
458       - openstack:
459           single-use: true
460
461 - publisher:
462     name: opendaylight-infra-generate-csit-status-report
463     publishers:
464       - postbuildscript:
465           builders:
466             - shell: !include-raw: generate-csit-status-report.sh
467           script-only-if-succeeded: false
468           script-only-if-failed: false
469           mark-unstable-if-failed: false