Chore: Update common-packer to latest v0.16.5
[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: opendaylight-infra-stack
252     # opendaylight-infra-stack.sh has a required variable {stack-template} that
253     # must be passed into this macro.
254     builders:
255       - shell: !include-raw: opendaylight-infra-stack.sh
256       - shell: !include-raw-escape: opendaylight-infra-copy-ssh-keys.sh
257
258 - builder:
259     name: opendaylight-apex-stack
260     # opendaylight-apex-stack.sh has a required variable {stack-template} that
261     # must be passed into this macro.
262     builders:
263       - shell: !include-raw: opendaylight-infra-stack.sh
264
265 - builder:
266     name: distribute-build-url
267     # Place URL of the current run of a build job to a file at given path.
268     builders:
269       - shell: |
270           #!/bin/bash
271           set +e  # DO NOT fail script if command returns non-zero.
272
273           echo "$BUILD_URL" > {path}/build.url
274
275           # DO NOT fail the build if the echo failed.
276           exit 0
277
278 - builder:
279     name: wipe-org-opendaylight-repo
280     builders:
281       - shell: 'if [ -d /tmp/r/org/opendaylight ]; then rm -rf /tmp/r/org/opendaylight; fi'
282
283 - builder:
284     name: wipe-local-maven-repo
285     builders:
286       - shell: 'if [ -d /tmp/r ]; then rm -rf /tmp/r; fi'
287
288 - publisher:
289     name: releng-openstack-stack-delete
290     publishers:
291       - postbuildscript:
292           builders:
293             - role: BOTH
294               build-on:
295                 - ABORTED
296                 - FAILURE
297                 - SUCCESS
298                 - UNSTABLE
299               build-steps:
300                 - shell: |
301                     #!/bin/bash -l
302                     echo "Deleting $STACK_NAME"
303                     openstack stack delete --yes "$STACK_NAME"
304           mark-unstable-if-failed: false
305
306 - wrapper:
307     # This wrapper is required for all jobs as it configures the wrappers
308     # needed by OpenDaylight infra.
309     name: opendaylight-infra-wrappers
310     wrappers:
311       - mask-passwords
312       - config-file-provider:
313           files:
314             - file-id: npmrc
315               target: '$HOME/.npmrc'
316             - file-id: pipconf
317               target: '$HOME/.config/pip/pip.conf'
318             - file-id: clouds-yaml
319               target: '$HOME/.config/openstack/clouds.yaml'
320       - timeout:
321           type: absolute
322           timeout: '{build-timeout}'
323           timeout-var: 'BUILD_TIMEOUT'
324           fail: true
325       - timestamps
326       - ssh-agent-credentials:
327           users:
328             - 'opendaylight-jenkins-ssh'
329       - openstack:
330           single-use: true
331
332 - publisher:
333     name: opendaylight-infra-generate-csit-status-report
334     publishers:
335       - postbuildscript:
336           builders:
337             - role: BOTH
338               build-on:
339                 - ABORTED
340                 - FAILURE
341                 - NOT_BUILT
342                 - SUCCESS
343                 - UNSTABLE
344               build-steps:
345                 - shell: !include-raw: generate-csit-status-report.sh
346           mark-unstable-if-failed: true