Merge "Update cloud image Ubuntu18.04 mininet ovs"
[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: |
33             Space separated glob patterns for artifacts to archive
34             into s3-logs.opendaylight.org/logs
35       - string:
36           name: GERRIT_PROJECT
37           default: "{project}"
38           description: "GERRIT_PROJECT parameter if not given by trigger"
39       - string:
40           name: GERRIT_BRANCH
41           default: "{branch}"
42           description: "JJB configured GERRIT_BRANCH parameter"
43       - string:
44           name: GERRIT_REFSPEC
45           default: "{refspec}"
46           description: |
47             Gerrit reference to checkout (ex: refs/heads/master,
48             refs/changes/48/61548/1 where 61548 is Gerrit change ID, 1 is
49             patch number and 48 is last two digits of change ID)
50       - string:
51           name: STACK_NAME
52           default: "$SILO-$JOB_NAME-$BUILD_NUMBER"
53           description: "Used by Heat to generate a unique stack & vm name"
54       - string:
55           name: OS_CLOUD
56           default: "{os-cloud}"
57           description: |
58             The name of a cloud configuration in clouds.yaml. OS_CLOUD is a
59             variable name that is significant to openstack client as a
60             environment variable. Please refer to the documentation for
61             further details.
62             https://docs.openstack.org/developer/python-openstackclient/
63
64 - parameter:
65     name: distribution-branch-to-build-parameter
66     parameters:
67       - string:
68           name: DISTRIBUTION_BRANCH_TO_BUILD
69           default: "master"
70           description: "distribution repo branch to build with"
71
72 - parameter:
73     name: maven-exec
74     parameters:
75       - string:
76           name: MVN
77           default: "/w/tools/hudson.tasks.Maven_MavenInstallation/{maven-version}/bin/mvn"
78           description: "Maven selector to be used by shell scripts"
79
80 - scm:
81     name: git-scm
82     scm:
83       - git:
84           credentials-id: "opendaylight-jenkins-ssh"
85           url: "$GIT_BASE"
86           refspec: ""
87           branches:
88             - "origin/{branch}"
89           skip-tag: true
90           wipe-workspace: true
91
92 - scm:
93     name: git-scm-with-submodules
94     scm:
95       - git:
96           credentials-id: "opendaylight-jenkins-ssh"
97           url: "$GIT_BASE"
98           refspec: ""
99           branches:
100             - "refs/heads/{branch}"
101           skip-tag: true
102           wipe-workspace: true
103           submodule:
104             recursive: true
105
106 - scm:
107     name: gerrit-trigger-scm
108     scm:
109       - git:
110           credentials-id: "opendaylight-jenkins-ssh"
111           url: "$GIT_BASE"
112           refspec: "{refspec}"
113           branches:
114             - "origin/$GERRIT_BRANCH"
115           skip-tag: true
116           choosing-strategy: "{choosing-strategy}"
117
118 # This is a single macro to use for all jobs who vote on every (relevant) patch set.
119 # Only 'recheck' trigger word is supported, it always triggers the full set of relevant jobs,
120 # in order to prevent Jenkins from starting only a subset and still voting Verified+1.
121 # Arguments:
122 #     gerrit-server-name: name of gerrit server to listen to
123 #     project: pattern to match triggering projects
124 #     branch: triggering branch name
125 #     files: pattern to match triggering filepaths
126 - trigger:
127     name: gerrit-trigger-patch-submitted
128     triggers:
129       - gerrit:
130           server-name: "{gerrit-server-name}"
131           trigger-on:
132             - patchset-created-event:
133                 exclude-drafts: true
134                 exclude-trivial-rebase: false
135                 exclude-no-code-change: false
136             - draft-published-event
137             - comment-added-contains-event:
138                 comment-contains-value: '^Patch Set[ ]+[0-9]+:([ ]+|[\n]+)(recheck|reverify)$'
139           projects:
140             - project-compare-type: ANT
141               project-pattern: "{project}"
142               branches:
143                 - branch-compare-type: ANT
144                   branch-pattern: "**/{branch}"
145               file-paths:
146                 - compare-type: ANT
147                   pattern: "{files}"
148               forbidden-file-paths:
149                 - compare-type: REG_EXP
150                   pattern: "{forbidden-files}"
151
152 # TODO: Unify argument names across gerrit-trigger-* macros.
153 - trigger:
154     name: gerrit-trigger-patch-merged
155     triggers:
156       - gerrit:
157           server-name: "{gerrit-server-name}"
158           trigger-on:
159             - change-merged-event
160             - comment-added-contains-event:
161                 comment-contains-value: "remerge$"
162           projects:
163             - project-compare-type: "ANT"
164               project-pattern: "{name}"
165               branches:
166                 - branch-compare-type: "ANT"
167                   branch-pattern: "**/{branch}"
168               file-paths:
169                 - compare-type: ANT
170                   pattern: "{files}"
171               forbidden-file-paths:
172                 - compare-type: REG_EXP
173                   pattern: "{forbidden-files}"
174           skip-vote:
175             successful: true
176             failed: true
177             unstable: true
178             notbuilt: true
179           # Force Jenkins always vote the values it should already have voted
180           # during the prior verify phase
181           override-votes: true
182           gerrit-build-started-verified-value: 1
183           gerrit-build-successful-verified-value: 1
184           gerrit-build-failed-verified-value: 1
185           gerrit-build-unstable-verified-value: 1
186           gerrit-build-notbuilt-verified-value: 1
187           gerrit-build-started-codereview-value: 0
188           gerrit-build-successful-codereview-value: 0
189           gerrit-build-failed-codereview-value: 0
190           gerrit-build-unstable-codereview-value: 0
191           gerrit-build-notbuilt-codereview-value: 0
192
193 - publisher:
194     name: email-notification
195     publishers:
196       - email-ext:
197           recipients: "{email-recipients}"
198           reply-to: ""
199           content-type: default
200           subject: "{email-prefix} $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!"
201           body: |
202             $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS:
203
204             Please refer to the logs server URL for console logs when possible
205             and use the Jenkins Build URL as a last resort.
206
207             Console Logs URL:
208             https://s3-logs.opendaylight.org/logs/$SILO/$JENKINS_HOSTNAME/$JOB_NAME/$BUILD_NUMBER
209
210             Jenkins Build URL:
211             $BUILD_URL
212           unstable: true
213           fixed: true
214           send-to:
215             - recipients
216
217 - builder:
218     name: opendaylight-infra-stack
219     # opendaylight-infra-stack.sh has a required variable {stack-template} that
220     # must be passed into this macro.
221     builders:
222       - shell: !include-raw: opendaylight-infra-stack.sh
223       - shell: !include-raw-escape: opendaylight-infra-copy-ssh-keys.sh
224
225 - builder:
226     name: distribute-build-url
227     # Place URL of the current run of a build job to a file at given path.
228     builders:
229       - shell: |
230           #!/bin/bash
231           set +e  # DO NOT fail script if command returns non-zero.
232
233           echo "$BUILD_URL" > {path}/build.url
234
235           # DO NOT fail the build if the echo failed.
236           exit 0
237
238 - builder:
239     name: wipe-org-opendaylight-repo
240     builders:
241       - shell: "if [ -d /tmp/r/org/opendaylight ]; then rm -rf /tmp/r/org/opendaylight; fi"
242
243 - builder:
244     name: wipe-local-maven-repo
245     builders:
246       - shell: "if [ -d /tmp/r ]; then rm -rf /tmp/r; fi"
247
248 - wrapper:
249     # This wrapper is required for all jobs as it configures the wrappers
250     # needed by OpenDaylight infra.
251     name: opendaylight-infra-wrappers
252     wrappers:
253       - mask-passwords
254       - config-file-provider:
255           files:
256             - file-id: npmrc
257               target: "$HOME/.npmrc"
258             - file-id: pipconf
259               target: "$HOME/.config/pip/pip.conf"
260             - file-id: clouds-yaml
261               target: "$HOME/.config/openstack/clouds.yaml"
262       - timeout:
263           type: absolute
264           timeout: "{build-timeout}"
265           timeout-var: "BUILD_TIMEOUT"
266           fail: true
267       - timestamps
268       - ssh-agent-credentials:
269           users:
270             - "opendaylight-jenkins-ssh"
271       - openstack:
272           single-use: true
273
274 - publisher:
275     name: opendaylight-infra-generate-csit-status-report
276     publishers:
277       - postbuildscript:
278           builders:
279             - role: BOTH
280               build-on:
281                 - ABORTED
282                 - FAILURE
283                 - NOT_BUILT
284                 - SUCCESS
285                 - UNSTABLE
286               build-steps:
287                 - shell: !include-raw: generate-csit-status-report.sh
288           mark-unstable-if-failed: true