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