789346582d90cd3a304e874bec6e41748ed21df0
[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
251 - builder:
252     # Installs the openstack cli into a virtualenv at /tmp/v/openstack
253     name: odl-openstack-install
254     builders:
255       - shell: !include-raw: odl-openstack-install.sh
256
257 - builder:
258     name: odl-openstack-check-image-protection
259     builders:
260       - shell: !include-raw: odl-openstack-check-image-protection.sh
261
262 - builder:
263     name: odl-openstack-cleanup-old-images
264     builders:
265       - shell: !include-raw: odl-openstack-cleanup-old-images.sh
266
267 - builder:
268     name: odl-openstack-cleanup-orphaned-nodes
269     builders:
270       - shell: !include-raw: odl-openstack-cleanup-orphaned-nodes.sh
271
272 - builder:
273     name: odl-openstack-cleanup-stale-nodes
274     builders:
275       - shell: !include-raw: odl-openstack-cleanup-stale-nodes.sh
276
277 - builder:
278     name: odl-openstack-cleanup-stale-stacks
279     builders:
280       - shell: !include-raw: odl-openstack-cleanup-stale-stacks.sh
281
282 - builder:
283     name: odl-openstack-cleanup-stale-volumes
284     builders:
285       - shell: !include-raw: odl-openstack-cleanup-stale-volumes.sh
286
287 - builder:
288     # Deploys a maven site to Nexus using lftools nexus-zip command
289     name: opendaylight-infra-deploy-maven-site
290     builders:
291       - lf-provide-maven-settings:
292           global-settings-file: global-settings
293           settings-file: '{settings-file}'
294       - lf-infra-create-netrc:
295           server-id: opendaylight-site
296       - shell: !include-raw-escape:
297           - global-jjb/shell/lftools-install.sh
298           - opendaylight-infra-deploy-maven-site.sh
299       - lf-provide-maven-settings-cleanup
300
301 - builder:
302     name: opendaylight-infra-stack
303     # opendaylight-infra-stack.sh has a required variable {stack-template} that
304     # must be passed into this macro.
305     builders:
306       - shell: !include-raw: opendaylight-infra-stack.sh
307       - shell: !include-raw-escape: opendaylight-infra-copy-ssh-keys.sh
308
309 - builder:
310     name: opendaylight-apex-stack
311     # opendaylight-apex-stack.sh has a required variable {stack-template} that
312     # must be passed into this macro.
313     builders:
314       - shell: !include-raw: opendaylight-infra-stack.sh
315
316 - builder:
317     name: distribute-build-url
318     # Place URL of the current run of a build job to a file at given path.
319     builders:
320       - shell: |
321           #!/bin/bash
322           set +e  # DO NOT fail script if command returns non-zero.
323
324           echo "$BUILD_URL" > {path}/build.url
325
326           # DO NOT fail the build if the echo failed.
327           exit 0
328
329 - builder:
330     name: wipe-org-opendaylight-repo
331     builders:
332       - shell: 'if [ -d /tmp/r/org/opendaylight ]; then rm -rf /tmp/r/org/opendaylight; fi'
333
334 - builder:
335     name: wipe-local-maven-repo
336     builders:
337       - shell: 'if [ -d /tmp/r ]; then rm -rf /tmp/r; fi'
338
339 - builder:
340     name: jacoco-nojava-workaround
341     builders:
342       - shell: 'mkdir -p $WORKSPACE/target/classes $WORKSPACE/jacoco/classes'
343
344 - builder:
345     name: provide-maven-settings
346     builders:
347       - config-file-provider:
348           files:
349             - file-id: '{global-settings-file}'
350               variable: 'GLOBAL_SETTINGS_FILE'
351             - file-id: '{settings-file}'
352               variable: 'SETTINGS_FILE'
353
354 - publisher:
355     name: releng-openstack-stack-delete
356     publishers:
357       - postbuildscript:
358           builders:
359             - role: BOTH
360               build-on:
361                 - ABORTED
362                 - FAILURE
363                 - SUCCESS
364                 - UNSTABLE
365               build-steps:
366                 - shell: |
367                     #!/bin/bash -l
368                     echo "Deleting $STACK_NAME"
369                     openstack stack delete --yes "$STACK_NAME"
370           mark-unstable-if-failed: false
371
372 - wrapper:
373     # This wrapper is required for all jobs as it configures the wrappers
374     # needed by OpenDaylight infra.
375     name: opendaylight-infra-wrappers
376     wrappers:
377       - mask-passwords
378       - config-file-provider:
379           files:
380             - file-id: npmrc
381               target: '$HOME/.npmrc'
382             - file-id: pipconf
383               target: '$HOME/.config/pip/pip.conf'
384             - file-id: clouds-yaml
385               target: '$HOME/.config/openstack/clouds.yaml'
386       - timeout:
387           type: absolute
388           timeout: '{build-timeout}'
389           timeout-var: 'BUILD_TIMEOUT'
390           fail: true
391       - timestamps
392       - ssh-agent-credentials:
393           users:
394             - 'opendaylight-jenkins-ssh'
395       - openstack:
396           single-use: true
397
398 - publisher:
399     name: opendaylight-infra-generate-csit-status-report
400     publishers:
401       - postbuildscript:
402           builders:
403             - role: BOTH
404               build-on:
405                 - ABORTED
406                 - FAILURE
407                 - NOT_BUILT
408                 - SUCCESS
409                 - UNSTABLE
410               build-steps:
411                 - shell: !include-raw: generate-csit-status-report.sh
412           mark-unstable-if-failed: true