Split distribution jobs
[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: '^Patch Set[ ]+[0-9]+:([ ]+|[\n]+)(recheck|reverify)$'
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               forbidden-file-paths:
222                 - compare-type: ANT
223                   pattern: '{forbidden-files}'
224
225 # TODO: Unify argument names across gerrit-trigger-* macros.
226 - trigger:
227     name: gerrit-trigger-patch-merged
228     triggers:
229       - gerrit:
230           server-name: '{gerrit-server-name}'
231           trigger-on:
232             - change-merged-event
233             - comment-added-contains-event:
234                 comment-contains-value: 'remerge$'
235           projects:
236             - project-compare-type: 'ANT'
237               project-pattern: '{name}'
238               branches:
239                 - branch-compare-type: 'ANT'
240                   branch-pattern: '**/{branch}'
241               file-paths:
242                 - compare-type: ANT
243                   pattern: '{files}'
244               forbidden-file-paths:
245                 - compare-type: ANT
246                   pattern: '{forbidden-files}'
247           skip-vote:
248             successful: true
249             failed: true
250             unstable: true
251             notbuilt: true
252           # Force Jenkins always vote the values it should already have voted
253           # during the prior verify phase
254           override-votes: true
255           gerrit-build-started-verified-value: 1
256           gerrit-build-successful-verified-value: 1
257           gerrit-build-failed-verified-value: 1
258           gerrit-build-unstable-verified-value: 1
259           gerrit-build-notbuilt-verified-value: 1
260           gerrit-build-started-codereview-value: 0
261           gerrit-build-successful-codereview-value: 0
262           gerrit-build-failed-codereview-value: 0
263           gerrit-build-unstable-codereview-value: 0
264           gerrit-build-notbuilt-codereview-value: 0
265
266 # TODO: Unify argument names across gerrit-trigger-* macros.
267 - trigger:
268     name: gerrit-trigger-patch-sonar
269     triggers:
270       - gerrit:
271           server-name: '{gerrit-server-name}'
272           trigger-on:
273             - comment-added-contains-event:
274                 comment-contains-value: 'run-sonar'
275           projects:
276             - project-compare-type: 'ANT'
277               project-pattern: '{name}'
278               branches:
279                 - branch-compare-type: 'ANT'
280                   branch-pattern: '**/master'
281           skip-vote:
282             successful: true
283             failed: true
284             unstable: true
285             notbuilt: true
286
287 - publisher:
288     name: email-notification
289     publishers:
290       - email-ext:
291           recipients: '{email-recipients}'
292           reply-to: ''
293           content-type: default
294           subject: '{email-prefix} $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!'
295           body: |
296               $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS:
297
298               Please refer to the logs server URL for console logs when possible
299               and use the Jenkins Build URL as a last resort.
300
301               Console Logs URL:
302               https://logs.opendaylight.org/$SILO/$JENKINS_HOSTNAME/$JOB_NAME/$BUILD_NUMBER
303
304               Jenkins Build URL:
305               $BUILD_URL
306           unstable: true
307           fixed: true
308           send-to:
309             - recipients
310
311
312 - builder:
313     # Installs the openstack cli into a virtualenv at /tmp/v/openstack
314     name: odl-openstack-install
315     builders:
316       - shell: !include-raw: odl-openstack-install.sh
317
318 - builder:
319     name: odl-openstack-check-image-protection
320     builders:
321       - shell: !include-raw: odl-openstack-check-image-protection.sh
322
323 - builder:
324     name: odl-openstack-cleanup-old-images
325     builders:
326       - shell: !include-raw: odl-openstack-cleanup-old-images.sh
327
328 - builder:
329     name: odl-openstack-cleanup-orphaned-nodes
330     builders:
331       - shell: !include-raw: odl-openstack-cleanup-orphaned-nodes.sh
332
333 - builder:
334     name: odl-openstack-cleanup-stale-nodes
335     builders:
336       - shell: !include-raw: odl-openstack-cleanup-stale-nodes.sh
337
338 - builder:
339     name: odl-openstack-cleanup-stale-stacks
340     builders:
341       - shell: !include-raw: odl-openstack-cleanup-stale-stacks.sh
342
343 - builder:
344     name: odl-openstack-cleanup-stale-volumes
345     builders:
346       - shell: !include-raw: odl-openstack-cleanup-stale-volumes.sh
347
348 - builder:
349     # Deploys a maven site to Nexus using lftools nexus-zip command
350     name: opendaylight-infra-deploy-maven-site
351     builders:
352       - lf-provide-maven-settings:
353           global-settings-file: global-settings
354           settings-file: '{settings-file}'
355       - lf-infra-create-netrc:
356           server-id: opendaylight-site
357       - shell: !include-raw-escape:
358           - global-jjb/shell/lftools-install.sh
359           - opendaylight-infra-deploy-maven-site.sh
360       - lf-provide-maven-settings-cleanup
361
362 - builder:
363     name: opendaylight-infra-stack
364     # opendaylight-infra-stack.sh has a required variable {stack-template} that
365     # must be passed into this macro.
366     builders:
367       - shell: !include-raw: opendaylight-infra-stack.sh
368       - shell: !include-raw-escape: opendaylight-infra-copy-ssh-keys.sh
369
370 - builder:
371     name: distribute-build-url
372     # Place URL of the current run of a build job to a file at given path.
373     builders:
374       - shell: |
375           #!/bin/bash
376           set +e  # DO NOT fail script if command returns non-zero.
377
378           echo "$BUILD_URL" > {path}/build.url
379
380           # DO NOT fail the build if the echo failed.
381           exit 0
382
383 - builder:
384     name: wipe-org-opendaylight-repo
385     builders:
386       - shell: 'if [ -d /tmp/r/org/opendaylight ]; then rm -rf /tmp/r/org/opendaylight; fi'
387
388 - builder:
389     name: wipe-local-maven-repo
390     builders:
391       - shell: 'if [ -d /tmp/r ]; then rm -rf /tmp/r; fi'
392
393 - builder:
394     name: jacoco-nojava-workaround
395     builders:
396       - shell: 'mkdir -p $WORKSPACE/target/classes $WORKSPACE/jacoco/classes'
397
398 - builder:
399     name: check-clm
400     builders:
401       - sonatype-clm:
402           application-name: '{application-name}'
403
404 - builder:
405     name: releng-check-unicode
406     builders:
407       - shell: |
408           $WORKSPACE/scripts/check-unicode.sh jjb/
409
410 - builder:
411     name: provide-maven-settings
412     builders:
413       - config-file-provider:
414           files:
415             - file-id: '{global-settings-file}'
416               variable: 'GLOBAL_SETTINGS_FILE'
417             - file-id: '{settings-file}'
418               variable: 'SETTINGS_FILE'
419
420 - builder:
421     name: releng-fetch-p2zip-if-necessary
422     builders:
423       - shell: |
424           # Cleanup any existing zips and metadata before we download the new update site
425           rm -f *.zip *.xml
426       - conditional-step:
427           condition-kind: strings-match
428           condition-string1: '$P2ZIP_URL'
429           condition-string2: ''
430           condition-basedir: workspace
431           steps:
432             # TODO: Figure out latest snapshot version number to pull rather than hardcoding 1.1.1-SNAPSHOT
433             - maven-target:
434                 maven-version: '{maven-version}'
435                 goals: >
436                     org.apache.maven.plugins:maven-dependency-plugin:get
437                     org.apache.maven.plugins:maven-dependency-plugin:copy
438                     -V -B
439                     -Dartifact=org.opendaylight.yangide:org.opendaylight.yangide.update-site:1.1.1-SNAPSHOT:zip
440                     -DoutputDirectory=$WORKSPACE
441                 settings: '{settings}'
442                 global-settings: '{global-settings}'
443
444 - builder:
445     name: releng-generate-p2pom
446     builders:
447       - shell: !include-raw: generate-p2pom.sh
448
449 - builder:
450     name: releng-update-p2composite-metadata
451     builders:
452       - shell: !include-raw: update-p2composite-metadata.sh
453       - conditional-step:
454           condition-kind: file-exists
455           condition-filename: deploy-composite-repo.xml
456           condition-basedir: workspace
457           steps:
458             - maven-target:
459                 maven-version: '{maven-version}'
460                 pom: 'deploy-composite-repo.xml'
461                 goals: 'clean deploy -V -B -Dmaven.repo.local=/tmp/r'
462                 settings: '{settings}'
463                 global-settings: '{global-settings}'
464
465 - publisher:
466     name: releng-openstack-stack-delete
467     publishers:
468       - postbuildscript:
469           builders:
470             - role: BOTH
471               build-on:
472                 - ABORTED
473                 - FAILURE
474                 - SUCCESS
475                 - UNSTABLE
476               build-steps:
477                 - shell: |
478                     #!/bin/bash
479                     echo "Deleting $STACK_NAME"
480                     source "/tmp/v/openstack/bin/activate"
481                     openstack stack delete --yes "$STACK_NAME"
482           mark-unstable-if-failed: false
483
484 - builder:
485     name: releng-stage-release
486     builders:
487       - shell: !include-raw: stage-release.sh
488
489 - wrapper:
490     # This wrapper is required for all jobs as it configures the wrappers
491     # needed by OpenDaylight infra.
492     name: opendaylight-infra-wrappers
493     wrappers:
494       - mask-passwords
495       - config-file-provider:
496           files:
497             - file-id: npmrc
498               target: '$HOME/.npmrc'
499             - file-id: pipconf
500               target: '$HOME/.config/pip/pip.conf'
501             - file-id: clouds-yaml
502               target: '$HOME/.config/openstack/clouds.yaml'
503       - timeout:
504           type: absolute
505           timeout: '{build-timeout}'
506           timeout-var: 'BUILD_TIMEOUT'
507           fail: true
508       - timestamps
509       - ssh-agent-credentials:
510           users:
511             - 'opendaylight-jenkins-ssh'
512       - openstack:
513           single-use: true
514
515 - publisher:
516     name: opendaylight-infra-generate-csit-status-report
517     publishers:
518       - postbuildscript:
519           builders:
520             - role: BOTH
521               build-on:
522                 - ABORTED
523                 - FAILURE
524                 - NOT_BUILT
525                 - SUCCESS
526                 - UNSTABLE
527               build-steps:
528                 - shell: !include-raw: generate-csit-status-report.sh
529           mark-unstable-if-failed: true