4a850e4c1ac78e455ef73cf6ea87392e76bb427e
[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: patches-to-build-parameter
64     parameters:
65       - string:
66           name: PATCHES_TO_BUILD
67           default: ''
68           description: |
69               Ordered list of patches to build in the format of project=changeset (checkout) or
70               project:changeset (cherry-pick) for example: genius=32/53632/9,netvirt:59/50259/47.
71               A topic is also allowed, for example: topic=binding-tlc-rpc
72
73 - parameter:
74     name: build-order-parameter
75     parameters:
76       - string:
77           name: BUILD_ORDER
78           default: '{build-order}'
79           description: 'Build order for multipatch test when topic is used'
80
81 - parameter:
82     name: build-fast-parameter
83     parameters:
84       - string:
85           name: BUILD_FAST
86           default: '{build-fast}'
87           description: 'Set true to build fast -Pq'
88
89 - parameter:
90     name: run-test-parameter
91     parameters:
92       - string:
93           name: RUN_TEST
94           default: '{run-test}'
95           description: 'Set true to run test after build'
96
97 - parameter:
98     name: distribution-branch-to-build-parameter
99     parameters:
100       - string:
101           name: DISTRIBUTION_BRANCH_TO_BUILD
102           default: 'master'
103           description: 'distribution repo branch to build with'
104
105 - parameter:
106     name: maven-exec
107     parameters:
108       - string:
109           name: MVN
110           default: '/w/tools/hudson.tasks.Maven_MavenInstallation/{maven-version}/bin/mvn'
111           description: 'Maven selector to be used by shell scripts'
112
113 - scm:
114     name: git-scm
115     scm:
116       - git:
117           credentials-id: 'opendaylight-jenkins-ssh'
118           url: '$GIT_BASE'
119           refspec: ''
120           branches:
121             - 'origin/{branch}'
122           skip-tag: true
123           wipe-workspace: true
124
125 - scm:
126     name: git-scm-with-submodules
127     scm:
128       - git:
129           credentials-id: 'opendaylight-jenkins-ssh'
130           url: '$GIT_BASE'
131           refspec: ''
132           branches:
133             - 'refs/heads/{branch}'
134           skip-tag: true
135           wipe-workspace: true
136           submodule:
137             recursive: true
138
139 - scm:
140     name: gerrit-trigger-scm
141     scm:
142       - git:
143           credentials-id: 'opendaylight-jenkins-ssh'
144           url: '$GIT_BASE'
145           refspec: '{refspec}'
146           branches:
147             - 'origin/$GERRIT_BRANCH'
148           skip-tag: true
149           choosing-strategy: '{choosing-strategy}'
150
151 # This is a single macro to use for all jobs who vote on every (relevant) patch set.
152 # Only 'recheck' trigger word is supported, it always triggers the full set of relevant jobs,
153 # in order to prevent Jenkins from starting only a subset and still voting Verified+1.
154 # Arguments:
155 #     gerrit-server-name: name of gerrit server to listen to
156 #     project: pattern to match triggering projects
157 #     branch: triggering branch name
158 #     files: pattern to match triggering filepaths
159 - trigger:
160     name: gerrit-trigger-patch-submitted
161     triggers:
162       - gerrit:
163           server-name: '{gerrit-server-name}'
164           trigger-on:
165             - patchset-created-event:
166                 exclude-drafts: true
167                 exclude-trivial-rebase: false
168                 exclude-no-code-change: false
169             - draft-published-event
170             - comment-added-contains-event:
171                 comment-contains-value: '^Patch Set[ ]+[0-9]+:([ ]+|[\n]+)(recheck|reverify)$'
172           projects:
173             - project-compare-type: ANT
174               project-pattern: '{project}'
175               branches:
176                 - branch-compare-type: ANT
177                   branch-pattern: '**/{branch}'
178               file-paths:
179                 - compare-type: ANT
180                   pattern: '{files}'
181               forbidden-file-paths:
182                 - compare-type: ANT
183                   pattern: '{forbidden-files}'
184
185 # TODO: Unify argument names across gerrit-trigger-* macros.
186 - trigger:
187     name: gerrit-trigger-patch-merged
188     triggers:
189       - gerrit:
190           server-name: '{gerrit-server-name}'
191           trigger-on:
192             - change-merged-event
193             - comment-added-contains-event:
194                 comment-contains-value: 'remerge$'
195           projects:
196             - project-compare-type: 'ANT'
197               project-pattern: '{name}'
198               branches:
199                 - branch-compare-type: 'ANT'
200                   branch-pattern: '**/{branch}'
201               file-paths:
202                 - compare-type: ANT
203                   pattern: '{files}'
204               forbidden-file-paths:
205                 - compare-type: ANT
206                   pattern: '{forbidden-files}'
207           skip-vote:
208             successful: true
209             failed: true
210             unstable: true
211             notbuilt: true
212           # Force Jenkins always vote the values it should already have voted
213           # during the prior verify phase
214           override-votes: true
215           gerrit-build-started-verified-value: 1
216           gerrit-build-successful-verified-value: 1
217           gerrit-build-failed-verified-value: 1
218           gerrit-build-unstable-verified-value: 1
219           gerrit-build-notbuilt-verified-value: 1
220           gerrit-build-started-codereview-value: 0
221           gerrit-build-successful-codereview-value: 0
222           gerrit-build-failed-codereview-value: 0
223           gerrit-build-unstable-codereview-value: 0
224           gerrit-build-notbuilt-codereview-value: 0
225
226 - publisher:
227     name: email-notification
228     publishers:
229       - email-ext:
230           recipients: '{email-recipients}'
231           reply-to: ''
232           content-type: default
233           subject: '{email-prefix} $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!'
234           body: |
235               $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS:
236
237               Please refer to the logs server URL for console logs when possible
238               and use the Jenkins Build URL as a last resort.
239
240               Console Logs URL:
241               https://logs.opendaylight.org/$SILO/$JENKINS_HOSTNAME/$JOB_NAME/$BUILD_NUMBER
242
243               Jenkins Build URL:
244               $BUILD_URL
245           unstable: true
246           fixed: true
247           send-to:
248             - recipients
249
250 - builder:
251     name: odl-openstack-check-image-protection
252     builders:
253       - shell: !include-raw: odl-openstack-check-image-protection.sh
254
255 - builder:
256     name: odl-openstack-cleanup-old-images
257     builders:
258       - shell: !include-raw: odl-openstack-cleanup-old-images.sh
259
260 - builder:
261     name: odl-openstack-cleanup-orphaned-nodes
262     builders:
263       - shell: !include-raw: odl-openstack-cleanup-orphaned-nodes.sh
264
265 - builder:
266     name: odl-openstack-cleanup-stale-nodes
267     builders:
268       - shell: !include-raw: odl-openstack-cleanup-stale-nodes.sh
269
270 - builder:
271     name: odl-openstack-cleanup-stale-stacks
272     builders:
273       - shell: !include-raw: odl-openstack-cleanup-stale-stacks.sh
274
275 - builder:
276     name: odl-openstack-cleanup-stale-volumes
277     builders:
278       - shell: !include-raw: odl-openstack-cleanup-stale-volumes.sh
279
280 - builder:
281     name: opendaylight-infra-stack
282     # opendaylight-infra-stack.sh has a required variable {stack-template} that
283     # must be passed into this macro.
284     builders:
285       - shell: !include-raw: opendaylight-infra-stack.sh
286       - shell: !include-raw-escape: opendaylight-infra-copy-ssh-keys.sh
287
288 - builder:
289     name: opendaylight-apex-stack
290     # opendaylight-apex-stack.sh has a required variable {stack-template} that
291     # must be passed into this macro.
292     builders:
293       - shell: !include-raw: opendaylight-infra-stack.sh
294
295 - builder:
296     name: distribute-build-url
297     # Place URL of the current run of a build job to a file at given path.
298     builders:
299       - shell: |
300           #!/bin/bash
301           set +e  # DO NOT fail script if command returns non-zero.
302
303           echo "$BUILD_URL" > {path}/build.url
304
305           # DO NOT fail the build if the echo failed.
306           exit 0
307
308 - builder:
309     name: wipe-org-opendaylight-repo
310     builders:
311       - shell: 'if [ -d /tmp/r/org/opendaylight ]; then rm -rf /tmp/r/org/opendaylight; fi'
312
313 - builder:
314     name: wipe-local-maven-repo
315     builders:
316       - shell: 'if [ -d /tmp/r ]; then rm -rf /tmp/r; fi'
317
318 - publisher:
319     name: releng-openstack-stack-delete
320     publishers:
321       - postbuildscript:
322           builders:
323             - role: BOTH
324               build-on:
325                 - ABORTED
326                 - FAILURE
327                 - SUCCESS
328                 - UNSTABLE
329               build-steps:
330                 - shell: |
331                     #!/bin/bash -l
332                     echo "Deleting $STACK_NAME"
333                     openstack stack delete --yes "$STACK_NAME"
334           mark-unstable-if-failed: false
335
336 - wrapper:
337     # This wrapper is required for all jobs as it configures the wrappers
338     # needed by OpenDaylight infra.
339     name: opendaylight-infra-wrappers
340     wrappers:
341       - mask-passwords
342       - config-file-provider:
343           files:
344             - file-id: npmrc
345               target: '$HOME/.npmrc'
346             - file-id: pipconf
347               target: '$HOME/.config/pip/pip.conf'
348             - file-id: clouds-yaml
349               target: '$HOME/.config/openstack/clouds.yaml'
350       - timeout:
351           type: absolute
352           timeout: '{build-timeout}'
353           timeout-var: 'BUILD_TIMEOUT'
354           fail: true
355       - timestamps
356       - ssh-agent-credentials:
357           users:
358             - 'opendaylight-jenkins-ssh'
359       - openstack:
360           single-use: true
361
362 - publisher:
363     name: opendaylight-infra-generate-csit-status-report
364     publishers:
365       - postbuildscript:
366           builders:
367             - role: BOTH
368               build-on:
369                 - ABORTED
370                 - FAILURE
371                 - NOT_BUILT
372                 - SUCCESS
373                 - UNSTABLE
374               build-steps:
375                 - shell: !include-raw: generate-csit-status-report.sh
376           mark-unstable-if-failed: true