Merge ~kzapalowicz/snappy-hwe-snaps/+git/jenkins-jobs:feature/deb-builds into ~snappy-hwe-team/snappy-hwe-snaps/+git/jenkins-jobs:master
- Git
- lp:~kzapalowicz/snappy-hwe-snaps/+git/jenkins-jobs
- feature/deb-builds
- Merge into master
Status: | Work in progress |
---|---|
Proposed branch: | ~kzapalowicz/snappy-hwe-snaps/+git/jenkins-jobs:feature/deb-builds |
Merge into: | ~snappy-hwe-team/snappy-hwe-snaps/+git/jenkins-jobs:master |
Diff against target: |
883 lines (+799/-0) 14 files modified
jobs/deb/common-job-prepare.sh (+58/-0) jobs/deb/deb-build-prepare.sh (+85/-0) jobs/deb/deb-build-prepare.yaml (+63/-0) jobs/deb/deb-build-worker.sh (+57/-0) jobs/deb/deb-build-worker.yaml (+72/-0) jobs/deb/deb-build.yaml (+90/-0) jobs/deb/deb-cleanup.sh (+38/-0) jobs/deb/deb-cleanup.yaml (+32/-0) jobs/deb/deb-project-jobs.yaml (+9/-0) jobs/deb/deb-trigger-ci.sh (+29/-0) jobs/deb/deb-trigger-ci.yaml (+22/-0) jobs/deb/deb-update-mp.sh (+30/-0) jobs/deb/deb-update-mp.yaml (+31/-0) tools/debbuild.sh (+183/-0) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
System Enablement Bot | continuous-integration | Approve | |
Simon Fels | Needs Fixing | ||
Review via email: mp+332172@code.launchpad.net |
Commit message
Description of the change
add jobs to build debian packages
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
- abb3609... by =?utf-8?q?Konrad_Zapa=C5=82owicz?= <email address hidden>
-
tools: add script to build debian packages in a chroot
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:b4acd0874a0
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
- 6de89e2... by =?utf-8?q?Konrad_Zapa=C5=82owicz?= <email address hidden>
-
jobs/deb: remove automerger
- 5a3a2d5... by =?utf-8?q?Konrad_Zapa=C5=82owicz?= <email address hidden>
-
jobs/deb: remove documentation building job
- ed4b1ad... by =?utf-8?q?Konrad_Zapa=C5=82owicz?= <email address hidden>
-
jobs.deb: save build results in results dir
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:80296ee4c46
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
- 47391cd... by =?utf-8?q?Konrad_Zapa=C5=82owicz?= <email address hidden>
-
jobs/deb: add CI_ID to identify all downstream builds with single id
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:47391cd4b34
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
Unmerged commits
- 47391cd... by =?utf-8?q?Konrad_Zapa=C5=82owicz?= <email address hidden>
-
jobs/deb: add CI_ID to identify all downstream builds with single id
- ed4b1ad... by =?utf-8?q?Konrad_Zapa=C5=82owicz?= <email address hidden>
-
jobs.deb: save build results in results dir
- 5a3a2d5... by =?utf-8?q?Konrad_Zapa=C5=82owicz?= <email address hidden>
-
jobs/deb: remove documentation building job
- 6de89e2... by =?utf-8?q?Konrad_Zapa=C5=82owicz?= <email address hidden>
-
jobs/deb: remove automerger
- abb3609... by =?utf-8?q?Konrad_Zapa=C5=82owicz?= <email address hidden>
-
tools: add script to build debian packages in a chroot
- 040f450... by =?utf-8?q?Konrad_Zapa=C5=82owicz?= <email address hidden>
-
jobs/deb: add build worker
- 915a1a3... by =?utf-8?q?Konrad_Zapa=C5=82owicz?= <email address hidden>
-
jobs/deb: add update MP job
- 19fa7b6... by =?utf-8?q?Konrad_Zapa=C5=82owicz?= <email address hidden>
-
jobs/deb: add documentation building job
- b782ce6... by =?utf-8?q?Konrad_Zapa=C5=82owicz?= <email address hidden>
-
jobs/deb: add cleanup job
- 7a52a3e... by =?utf-8?q?Konrad_Zapa=C5=82owicz?= <email address hidden>
-
jobs/deb: add deb build job
Preview Diff
1 | diff --git a/jobs/deb/common-job-prepare.sh b/jobs/deb/common-job-prepare.sh |
2 | new file mode 100644 |
3 | index 0000000..204a87d |
4 | --- /dev/null |
5 | +++ b/jobs/deb/common-job-prepare.sh |
6 | @@ -0,0 +1,58 @@ |
7 | +#!/bin/sh -ex |
8 | +# |
9 | +# Copyright (C) 2017 Canonical Ltd |
10 | +# |
11 | +# This program is free software: you can redistribute it and/or modify |
12 | +# it under the terms of the GNU General Public License version 3 as |
13 | +# published by the Free Software Foundation. |
14 | +# |
15 | +# This program is distributed in the hope that it will be useful, |
16 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 | +# GNU General Public License for more details. |
19 | +# |
20 | +# You should have received a copy of the GNU General Public License |
21 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
22 | + |
23 | +# This is a common place to be a forwarder of varibles definied in |
24 | +# the job definition. To avoid using templating in the actual job |
25 | +# shell script we have a common .sh file which does this for us. |
26 | +# |
27 | +# Whenever you need something which is suitable for multiple jobs |
28 | +# or originates from the job definition and needs to be added |
29 | +# through a template variable inside the shell script this |
30 | +# is the right place for it. |
31 | +# |
32 | +# This file will be sourced by all jobs. |
33 | + |
34 | +JENKINS_JOBS_GIT_REPO="{jobs-git-repo}" |
35 | +JENKINS_JOBS_GIT_REPO_BRANCH="{jobs-git-repo-branch}" |
36 | + |
37 | +# Ensure we have a clean and empty workspace but keep our jenkins-jobs |
38 | +# repository so we don't have to clone it again |
39 | +for f in $(ls "${{WORKSPACE}}"); do |
40 | + if [ "${{f}}" = jenkins-jobs ]; then |
41 | + continue |
42 | + fi |
43 | + rm -rf "${{WORKSPACE}}"/"${{f}}" |
44 | +done |
45 | + |
46 | +if [ -e jenkins-jobs ] ; then |
47 | + (cd jenkins-jobs ; git clean -fdx . ; git fetch origin ; git reset --hard origin/${{JENKINS_JOBS_GIT_REPO_BRANCH}}) |
48 | +else |
49 | + git clone -b ${{JENKINS_JOBS_GIT_REPO_BRANCH}} ${{JENKINS_JOBS_GIT_REPO}} |
50 | +fi |
51 | + |
52 | +cat << EOF > $WORKSPACE/.build_env |
53 | +BOT_USERNAME={bot_username} |
54 | +LAUNCHPAD_PROJECT={launchpad_project} |
55 | +LAUNCHPAD_TEAM={launchpad_team} |
56 | +DEB_BUILD_JOB={name}-deb-build-prepare |
57 | +BUILD_SCRIPTS=$WORKSPACE/jenkins-jobs |
58 | +BUILD_ON_LAUNCHPAD={build_on_launchpad} |
59 | +AUTO_MERGE={auto_merge} |
60 | +TRIGGER_CI={trigger_ci} |
61 | +UPDATE_MPS={update_mps} |
62 | +RUN_TESTS={run_tests} |
63 | +CI_REPO=ci-build-${{CI_ID}} |
64 | +EOF |
65 | diff --git a/jobs/deb/deb-build-prepare.sh b/jobs/deb/deb-build-prepare.sh |
66 | new file mode 100644 |
67 | index 0000000..1ee6fae |
68 | --- /dev/null |
69 | +++ b/jobs/deb/deb-build-prepare.sh |
70 | @@ -0,0 +1,85 @@ |
71 | +#!/bin/bash |
72 | +# |
73 | +# Copyright (C) 2017 Canonical Ltd |
74 | +# |
75 | +# This program is free software: you can redistribute it and/or modify |
76 | +# it under the terms of the GNU General Public License version 3 as |
77 | +# published by the Free Software Foundation. |
78 | +# |
79 | +# This program is distributed in the hope that it will be useful, |
80 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
81 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
82 | +# GNU General Public License for more details. |
83 | +# |
84 | +# You should have received a copy of the GNU General Public License |
85 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
86 | + |
87 | +set -ex |
88 | + |
89 | +. "$WORKSPACE/.build_env" |
90 | + |
91 | +# CI_ID isn't specified yet when we're being called so initialize |
92 | +# it here with the same value as we do in deb-build-prepare.yaml |
93 | +if [ -z "$CI_ID" ]; then |
94 | + CI_ID=$BUILD_ID |
95 | +fi |
96 | + |
97 | +rm -rf $WORKSPACE/src |
98 | + |
99 | +git clone --no-checkout $TARGET_GIT_REPO $WORKSPACE/src |
100 | +cd $WORKSPACE/src |
101 | +for remote in $(git branch -r | grep -v origin/master); do |
102 | + git checkout --track $remote |
103 | +done |
104 | + |
105 | +git checkout $TARGET_GIT_REPO_BRANCH |
106 | + |
107 | +git config user.name "System Enablement CI Bot" |
108 | +git config user.email "ce-system-enablement@lists.canonical.com" |
109 | + |
110 | +if [ -n "$SOURCE_GIT_REPO" ]; then |
111 | + git remote add other $SOURCE_GIT_REPO |
112 | + git fetch other |
113 | + git merge \ |
114 | + --no-ff \ |
115 | + -m "Merge remote tracking branch other/$SOURCE_GIT_REPO_BRANCH" \ |
116 | + $REVISION |
117 | +fi |
118 | + |
119 | +# Try to find the correct branch we need to build from. In the case that |
120 | +# $TARGET_GIT_REPO_BRANCH points us to an upstream component branch we |
121 | +# will take master as the next suitable candidate. |
122 | +CI_BRANCH= |
123 | +DEBIAN_DIRECTORY_PATH= |
124 | +for branch in $TARGET_GIT_REPO_BRANCH master ; do |
125 | + git checkout $branch |
126 | + if [ -d debian ]; then |
127 | + DEBIAN_DIRECTORY_PATH=debian |
128 | + fi |
129 | + |
130 | + if [ -n "$DEBIAN_DIRECTORY_PATH" ]; then |
131 | + CI_BRANCH=$branch |
132 | + break |
133 | + fi |
134 | +done |
135 | + |
136 | +if [ -z "$CI_BRANCH" ]; then |
137 | + echo "WARNING: Can't build snap as no snapcraft.yaml exists!" |
138 | + exit 0 |
139 | +fi |
140 | + |
141 | +# Now let's setup some variables that are important for the build process |
142 | + |
143 | +REPO_NAME=$(awk -v a="$TARGET_GIT_REPO" 'BEGIN{print substr(a, index(a, "+git/") + 5)}') |
144 | +# We rely on the snapcraft.yaml to have the snap name in the first five lines |
145 | +# which is the case for all our snaps. This is a bit lazy but the best way to |
146 | +# ensure we don't fetch any other name: fields which might be present in the file. |
147 | +DEB_NAME=$(cat $DEBIAN_DIRECTORY_PATH/control | grep "^Source:" | awk '{print $2}') |
148 | +DEB_REV=$(git rev-parse --short HEAD) |
149 | +CI_REPO=ci-build-$CI_ID |
150 | + |
151 | +# Push to CI repository |
152 | + |
153 | +git remote add jenkins-ci git+ssh://$BOT_USERNAME@git.launchpad.net/~$LAUNCHPAD_TEAM/$LAUNCHPAD_PROJECT/+git/$CI_REPO |
154 | +git push jenkins-ci --all |
155 | +git push jenkins-ci --tags |
156 | diff --git a/jobs/deb/deb-build-prepare.yaml b/jobs/deb/deb-build-prepare.yaml |
157 | new file mode 100644 |
158 | index 0000000..c75f803 |
159 | --- /dev/null |
160 | +++ b/jobs/deb/deb-build-prepare.yaml |
161 | @@ -0,0 +1,63 @@ |
162 | +- job-template: |
163 | + name: '{name}-deb-build-prepare' |
164 | + project-type: freestyle |
165 | + defaults: global |
166 | + description: "" |
167 | + display-name: "{name}-deb-build-prepare" |
168 | + concurrent: true |
169 | + node: deb && misc |
170 | + properties: |
171 | + - build-discarder: |
172 | + num-to-kep: 10 |
173 | + - rebuild |
174 | + parameters: |
175 | + - string: |
176 | + name: TARGET_GIT_REPO |
177 | + default: |
178 | + description: "Target git repository" |
179 | + - string: |
180 | + name: TARGET_GIT_REPO_BRANCH |
181 | + default: master |
182 | + description: "Branch of the target git repository to build from" |
183 | + - string: |
184 | + name: SERIES |
185 | + default: xenial |
186 | + description: "Ubuntu archive series to build for" |
187 | + - string: |
188 | + name: FORCE |
189 | + default: "0" |
190 | + description: "Set to 1 to force the build" |
191 | + - string: |
192 | + name: SOURCE_GIT_REPO |
193 | + default: |
194 | + description: "Source git repository" |
195 | + - string: |
196 | + name: SOURCE_GIT_REPO_BRANCH |
197 | + default: |
198 | + description: "Branch of the source git repository to use" |
199 | + - string: |
200 | + name: MERGE_PROPOSAL |
201 | + default: |
202 | + description: "Link to the merge proposal this build relates to" |
203 | + - string: |
204 | + name: REVISION |
205 | + default: |
206 | + description: "Git revision that is being build" |
207 | + - string: |
208 | + name: CLEANUP_WORKSPACE |
209 | + default: "0" |
210 | + description: "Cleanup the whole workspace" |
211 | + builders: |
212 | + - shell: |
213 | + !include-raw: |
214 | + - common-job-prepare.sh |
215 | + - shell: |
216 | + !include-raw-escape: |
217 | + - deb-build-prepare.sh |
218 | + - trigger-builds: |
219 | + - project: '{name}-deb-build' |
220 | + current-parameters: true |
221 | + predefined-parameters: | |
222 | + CI_ID=$BUILD_ID |
223 | + RESULTS_ID=$BUILD_TAG |
224 | + block: true |
225 | diff --git a/jobs/deb/deb-build-worker.sh b/jobs/deb/deb-build-worker.sh |
226 | new file mode 100644 |
227 | index 0000000..56c7481 |
228 | --- /dev/null |
229 | +++ b/jobs/deb/deb-build-worker.sh |
230 | @@ -0,0 +1,57 @@ |
231 | +#!/bin/sh |
232 | +# |
233 | +# Copyright (C) 2017 Canonical Ltd |
234 | +# |
235 | +# This program is free software: you can redistribute it and/or modify |
236 | +# it under the terms of the GNU General Public License version 3 as |
237 | +# published by the Free Software Foundation. |
238 | +# |
239 | +# This program is distributed in the hope that it will be useful, |
240 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
241 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
242 | +# GNU General Public License for more details. |
243 | +# |
244 | +# You should have received a copy of the GNU General Public License |
245 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
246 | + |
247 | +set -ex |
248 | + |
249 | +. "$WORKSPACE/.build_env" |
250 | + |
251 | +rm -rf $WORKSPACE/src $WORKSPACE/results |
252 | + |
253 | +# Debian packages will be build in chroot for the host architecture using |
254 | +# bits from https://launchpad.net/jenkaas-jobs to do the job. |
255 | + |
256 | +DEBBUILD_EXTRA_ARGS= |
257 | + |
258 | +sudo $BUILD_SCRIPTS/tools/debbuild.sh \ |
259 | + --source-dir=$WORKSPACE/src \ |
260 | + --results-dir=$WORKSPACE/results \ |
261 | + --arch=$ARCHITECTURE \ |
262 | + --series=$SERIES \ |
263 | + --proxy=http://squid.internal:3128 \ |
264 | + $DEBBUILD_EXTRA_ARGS |
265 | + |
266 | +# Build is done, now copy the build artifacts to the remote location |
267 | + |
268 | +if [ -z "$REMOTE_WORKER" ]; then |
269 | + echo "INFO: No remote worker defined, not copying artifacts to it" |
270 | + exit 0 |
271 | +fi |
272 | + |
273 | +SSH_PATH="${JENKINS_HOME}/.ssh/" |
274 | +SSH_KEY_PATH="${SSH_PATH}/git.launchpad.net/$BOT_USERNAME" |
275 | +SSH="ssh -i $SSH_KEY_PATH/id_rsa $REMOTE_USER@$REMOTE_WORKER" |
276 | +SCP="scp -i $SSH_KEY_PATH/id_rsa" |
277 | + |
278 | +REMOTE_RESULTS_BASE_DIR=/home/$REMOTE_USER/results |
279 | + |
280 | +$SSH mkdir -p $REMOTE_RESULTS_BASE_DIR/$RESULTS_ID |
281 | +$SCP $WORKSPACE/results/*.deb $REMOTE_USER@$REMOTE_WORKER:$REMOTE_RESULTS_BASE_DIR/$RESULTS_ID/ |
282 | + |
283 | +# Save the id of our results so it can be used by a subsequent build |
284 | +# in a properties file which is then being read from jenkins and its |
285 | +# content passed as parameters to triggered builds. |
286 | +echo "RESULTS_ID=$RESULTS_ID" >> $WORKSPACE/build-props |
287 | +cat $WORKSPACE/build-props |
288 | diff --git a/jobs/deb/deb-build-worker.yaml b/jobs/deb/deb-build-worker.yaml |
289 | new file mode 100644 |
290 | index 0000000..18b09b8 |
291 | --- /dev/null |
292 | +++ b/jobs/deb/deb-build-worker.yaml |
293 | @@ -0,0 +1,72 @@ |
294 | +- job-template: |
295 | + name: '{name}-deb-build-worker' |
296 | + project-type: freestyle |
297 | + defaults: global |
298 | + description: "Build a deb on launchpad" |
299 | + display-name: "{name}-deb-build-worker" |
300 | + concurrent: true |
301 | + node: deb && build |
302 | + parameters: |
303 | + - string: |
304 | + name: ARCHITECTURE |
305 | + default: amd64 |
306 | + description: Architecture to build the deb for |
307 | + - string: |
308 | + name: TARGET_GIT_REPO |
309 | + default: |
310 | + description: "Target git repository" |
311 | + - string: |
312 | + name: TARGET_GIT_REPO_BRANCH |
313 | + default: master |
314 | + description: "Branch of the target git repository to build from" |
315 | + - string: |
316 | + name: SERIES |
317 | + default: xenial |
318 | + description: "Ubuntu archive series to build for" |
319 | + - string: |
320 | + name: FORCE |
321 | + default: "0" |
322 | + description: "Set to 1 to force the build" |
323 | + - string: |
324 | + name: SOURCE_GIT_REPO |
325 | + default: |
326 | + description: "Source git repository" |
327 | + - string: |
328 | + name: SOURCE_GIT_REPO_BRANCH |
329 | + default: |
330 | + description: "Branch of the source git repository to use" |
331 | + - string: |
332 | + name: MERGE_PROPOSAL |
333 | + default: |
334 | + description: "Link to the merge proposal this build relates to" |
335 | + - string: |
336 | + name: REVISION |
337 | + default: |
338 | + description: "Git revision that is being build" |
339 | + - string: |
340 | + name: CLEANUP_WORKSPACE |
341 | + default: "0" |
342 | + description: "Cleanup the whole workspace" |
343 | + - string: |
344 | + name: REMOTE_WORKER |
345 | + default: "{obj:remote_worker}" |
346 | + description: "The remote server to execute the spread jobs on. There's no need to change from the default value unless you know what you're doing." |
347 | + - string: |
348 | + name: REMOTE_USER |
349 | + default: "{obj:remote_user}" |
350 | + description: "The remote server username used to ssh to $REMOTE_WORKER." |
351 | + - string: |
352 | + name: CI_ID |
353 | + default: '' |
354 | + description: "Numeric id which will identify the CI iteration through all downstream builds" |
355 | + - string: |
356 | + name: RESULTS_ID |
357 | + default: '' |
358 | + description: "Alphanumeric identifier used to pass build artifacts through different jobs" |
359 | + builders: |
360 | + - shell: |
361 | + !include-raw: |
362 | + - common-job-prepare.sh |
363 | + - shell: |
364 | + !include-raw-escape: |
365 | + - deb-build-worker.sh |
366 | diff --git a/jobs/deb/deb-build.yaml b/jobs/deb/deb-build.yaml |
367 | new file mode 100644 |
368 | index 0000000..4a11d32 |
369 | --- /dev/null |
370 | +++ b/jobs/deb/deb-build.yaml |
371 | @@ -0,0 +1,90 @@ |
372 | +- job-template: |
373 | + name: '{name}-deb-build' |
374 | + project-type: matrix |
375 | + defaults: global |
376 | + description: "Build a deb with subsequent test execution" |
377 | + display-name: "{name}-deb-build" |
378 | + concurrent: true |
379 | + sequential: false |
380 | + node: monitor |
381 | + axes: |
382 | + - axis: |
383 | + type: user-defined |
384 | + name: ARCHITECTURE |
385 | + values: '{obj:build_architectures}' |
386 | + parameters: |
387 | + - string: |
388 | + name: TARGET_GIT_REPO |
389 | + default: |
390 | + description: "Target git repository" |
391 | + - string: |
392 | + name: TARGET_GIT_REPO_BRANCH |
393 | + default: master |
394 | + description: "Branch of the target git repository to build from" |
395 | + - string: |
396 | + name: SERIES |
397 | + default: xenial |
398 | + description: "Ubuntu archive series to build for" |
399 | + - string: |
400 | + name: FORCE |
401 | + default: "0" |
402 | + description: "Set to 1 to force the build" |
403 | + - string: |
404 | + name: SOURCE_GIT_REPO |
405 | + default: |
406 | + description: "Source git repository" |
407 | + - string: |
408 | + name: SOURCE_GIT_REPO_BRANCH |
409 | + default: |
410 | + description: "Branch of the source git repository to use" |
411 | + - string: |
412 | + name: MERGE_PROPOSAL |
413 | + default: |
414 | + description: "Link to the merge proposal this build relates to" |
415 | + - string: |
416 | + name: REVISION |
417 | + default: |
418 | + description: "Cleanup the whole workspace" |
419 | + - string: |
420 | + name: CLEANUP_WORKSPACE |
421 | + default: "0" |
422 | + description: "Cleanup the whole workspace" |
423 | + - string: |
424 | + name: CI_ID |
425 | + default: '' |
426 | + description: "Numeric id which will identify the CI iteration through all downstream builds" |
427 | + builders: |
428 | + - trigger-builds: |
429 | + - project: '{name}-deb-build-worker' |
430 | + current-parameters: true |
431 | + predefined-parameters: | |
432 | + ARCHITECTURE=$ARCHITECTURE |
433 | + block: true |
434 | + - project: '{name}-deb-docs' |
435 | + current-parameters: true |
436 | + block: true |
437 | + - project: '{name}-deb-cleanup' |
438 | + current-parameters: true |
439 | + publishers: |
440 | + - archive: |
441 | + artifacts: '**/*.deb' |
442 | + latest-only: false |
443 | + allow-empty: true |
444 | + fingerprint: false |
445 | + - trigger-parameterized-builds: |
446 | + - project: '{name}-deb-update-mp' |
447 | + condition: "SUCCESS" |
448 | + predefined-parameters: | |
449 | + CI_RESULT=PASSED |
450 | + CI_BUILD=${{BUILD_URL}} |
451 | + CI_BRANCH="${{SOURCE_GIT_REPO_BRANCH}}@${{SOURCE_GIT_REPO}}" |
452 | + CI_MERGE_PROPOSAL=${{MERGE_PROPOSAL}} |
453 | + CI_REVISION=${{REVISION}} |
454 | + - project: '{name}-deb-update-mp' |
455 | + condition: "UNSTABLE_OR_WORSE" |
456 | + predefined-parameters: | |
457 | + CI_RESULT=FAILED |
458 | + CI_BUILD=${{BUILD_URL}} |
459 | + CI_BRANCH="${{SOURCE_GIT_REPO_BRANCH}}@${{SOURCE_GIT_REPO}}" |
460 | + CI_MERGE_PROPOSAL=${{MERGE_PROPOSAL}} |
461 | + CI_REVISION=${{REVISION}} |
462 | diff --git a/jobs/deb/deb-cleanup.sh b/jobs/deb/deb-cleanup.sh |
463 | new file mode 100644 |
464 | index 0000000..bf0e03c |
465 | --- /dev/null |
466 | +++ b/jobs/deb/deb-cleanup.sh |
467 | @@ -0,0 +1,38 @@ |
468 | +#!/bin/sh |
469 | +# |
470 | +# Copyright (C) 2017 Canonical Ltd |
471 | +# |
472 | +# This program is free software: you can redistribute it and/or modify |
473 | +# it under the terms of the GNU General Public License version 3 as |
474 | +# published by the Free Software Foundation. |
475 | +# |
476 | +# This program is distributed in the hope that it will be useful, |
477 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
478 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
479 | +# GNU General Public License for more details. |
480 | +# |
481 | +# You should have received a copy of the GNU General Public License |
482 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
483 | + |
484 | +set -x |
485 | + |
486 | +. "$WORKSPACE/.build_env" |
487 | + |
488 | +# Delete auxiliary repo used in the build |
489 | +$BUILD_SCRIPTS/tools/delete-ci-repo.py \ |
490 | + --git-repo=https://git.launchpad.net/~$LAUNCHPAD_TEAM/$LAUNCHPAD_PROJECT/+git/$CI_REPO |
491 | + |
492 | +if [ -z "$REMOTE_WORKER" ]; then |
493 | + echo "INFO: No remote system defined" |
494 | + exit 0 |
495 | +fi |
496 | + |
497 | +SSH_PATH="${JENKINS_HOME}/.ssh/" |
498 | +SSH_KEY_PATH="${SSH_PATH}/git.launchpad.net/$BOT_USERNAME" |
499 | +SSH="ssh -i $SSH_KEY_PATH/id_rsa $REMOTE_USER@$REMOTE_WORKER" |
500 | +REMOTE_RESULTS_BASE_DIR=/home/$REMOTE_USER/results |
501 | + |
502 | +$SSH rm -rf $REMOTE_RESULTS_BASE_DIR/$RESULTS_ID |
503 | + |
504 | +# Now remove any container that might have been left behind... |
505 | +$SSH sudo docker rm \$\(sudo docker ps -q --filter=status=exited --filter=ancestor=snap-spread-tests\) || true |
506 | diff --git a/jobs/deb/deb-cleanup.yaml b/jobs/deb/deb-cleanup.yaml |
507 | new file mode 100644 |
508 | index 0000000..1b6480e |
509 | --- /dev/null |
510 | +++ b/jobs/deb/deb-cleanup.yaml |
511 | @@ -0,0 +1,32 @@ |
512 | +- job-template: |
513 | + name: '{name}-deb-cleanup' |
514 | + project-type: freestyle |
515 | + defaults: global |
516 | + description: "Cleanup artifacts left over from a deb build" |
517 | + display-name: "{name}-deb-cleanup" |
518 | + concurrent: true |
519 | + node: deb && build |
520 | + parameters: |
521 | + - string: |
522 | + name: CI_ID |
523 | + default: '' |
524 | + description: "Numeric id which will identify the CI iteration through all downstream builds" |
525 | + - string: |
526 | + name: RESULTS_ID |
527 | + default: "" |
528 | + description: "Alphanumeric Id of the results being staged on the remote worker" |
529 | + - string: |
530 | + name: REMOTE_WORKER |
531 | + default: "{obj:remote_worker}" |
532 | + description: "The remote server to execute the spread jobs on. There's no need to change from the default value unless you know what you're doing." |
533 | + - string: |
534 | + name: REMOTE_USER |
535 | + default: "{obj:remote_user}" |
536 | + description: "The remote server username used to ssh to $REMOTE_WORKER." |
537 | + builders: |
538 | + - shell: |
539 | + !include-raw: |
540 | + - common-job-prepare.sh |
541 | + - shell: |
542 | + !include-raw-escape: |
543 | + - deb-cleanup.sh |
544 | diff --git a/jobs/deb/deb-project-jobs.yaml b/jobs/deb/deb-project-jobs.yaml |
545 | new file mode 100644 |
546 | index 0000000..fbcef68 |
547 | --- /dev/null |
548 | +++ b/jobs/deb/deb-project-jobs.yaml |
549 | @@ -0,0 +1,9 @@ |
550 | +- job-group: |
551 | + name: deb-project-jobs |
552 | + jobs: |
553 | + - '{name}-deb-build-worker' |
554 | + - '{name}-deb-build' |
555 | + - '{name}-deb-build-prepare' |
556 | + - '{name}-deb-cleanup' |
557 | + - '{name}-deb-trigger-ci' |
558 | + - '{name}-deb-update-mp' |
559 | diff --git a/jobs/deb/deb-trigger-ci.sh b/jobs/deb/deb-trigger-ci.sh |
560 | new file mode 100644 |
561 | index 0000000..5430189 |
562 | --- /dev/null |
563 | +++ b/jobs/deb/deb-trigger-ci.sh |
564 | @@ -0,0 +1,29 @@ |
565 | +#!/bin/bash |
566 | +# |
567 | +# Copyright (C) 2016 Canonical Ltd |
568 | +# |
569 | +# This program is free software: you can redistribute it and/or modify |
570 | +# it under the terms of the GNU General Public License version 3 as |
571 | +# published by the Free Software Foundation. |
572 | +# |
573 | +# This program is distributed in the hope that it will be useful, |
574 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
575 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
576 | +# GNU General Public License for more details. |
577 | +# |
578 | +# You should have received a copy of the GNU General Public License |
579 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
580 | + |
581 | +set -ex |
582 | + |
583 | +. "$WORKSPACE/.build_env" |
584 | + |
585 | +if [ "$TRIGGER_CI" = False ]; then |
586 | + echo "WARNING: CI is disabled" |
587 | + exit 0 |
588 | +fi |
589 | + |
590 | +exec "$BUILD_SCRIPTS"/tools/trigger-ci.py \ |
591 | + -p "$LAUNCHPAD_PROJECT" \ |
592 | + -j "$DEB_BUILD_JOB" \ |
593 | + -t "$LAUNCHPAD_TEAM" |
594 | diff --git a/jobs/deb/deb-trigger-ci.yaml b/jobs/deb/deb-trigger-ci.yaml |
595 | new file mode 100644 |
596 | index 0000000..03d71ac |
597 | --- /dev/null |
598 | +++ b/jobs/deb/deb-trigger-ci.yaml |
599 | @@ -0,0 +1,22 @@ |
600 | +- job-template: |
601 | + name: '{name}-deb-trigger-ci' |
602 | + project-type: freestyle |
603 | + defaults: global |
604 | + description: "Monitor Launchpad for new merge proposals" |
605 | + display-name: "{name}-deb-trigger-ci" |
606 | + concurrent: true |
607 | + node: deb && misc |
608 | + triggers: |
609 | + - timed: # every five minutes |
610 | + H/5 * * * * |
611 | + properties: |
612 | + - build-discarder: |
613 | + num-to-keep: 10 |
614 | + - rebuild |
615 | + builders: |
616 | + - shell: |
617 | + !include-raw: |
618 | + - common-job-prepare.sh |
619 | + - shell: |
620 | + !include-raw-escape: |
621 | + - deb-trigger-ci.sh |
622 | diff --git a/jobs/deb/deb-update-mp.sh b/jobs/deb/deb-update-mp.sh |
623 | new file mode 100644 |
624 | index 0000000..e70e35c |
625 | --- /dev/null |
626 | +++ b/jobs/deb/deb-update-mp.sh |
627 | @@ -0,0 +1,30 @@ |
628 | +#!/bin/sh |
629 | +# |
630 | +# Copyright (C) 2017 Canonical Ltd |
631 | +# |
632 | +# This program is free software: you can redistribute it and/or modify |
633 | +# it under the terms of the GNU General Public License version 3 as |
634 | +# published by the Free Software Foundation. |
635 | +# |
636 | +# This program is distributed in the hope that it will be useful, |
637 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
638 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
639 | +# GNU General Public License for more details. |
640 | +# |
641 | +# You should have received a copy of the GNU General Public License |
642 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
643 | + |
644 | +set -ex |
645 | + |
646 | +. "$WORKSPACE/.build_env" |
647 | + |
648 | +if [ "$UPDATE_MPS" = False ]; then |
649 | + echo "WARNING: MP updates are disabled" |
650 | + exit 0 |
651 | +fi |
652 | + |
653 | +exec $BUILD_SCRIPTS/tools/vote-on-merge-proposal.py \ |
654 | + -s $CI_RESULT \ |
655 | + -u $CI_BUILD \ |
656 | + -r $CI_REVISION \ |
657 | + -p $CI_MERGE_PROPOSAL |
658 | diff --git a/jobs/deb/deb-update-mp.yaml b/jobs/deb/deb-update-mp.yaml |
659 | new file mode 100644 |
660 | index 0000000..6b26001 |
661 | --- /dev/null |
662 | +++ b/jobs/deb/deb-update-mp.yaml |
663 | @@ -0,0 +1,31 @@ |
664 | +- job-template: |
665 | + name: '{name}-deb-update-mp' |
666 | + project-type: freestyle |
667 | + defaults: global |
668 | + description: "Update given merge-proposal with the result of the build" |
669 | + display-name: "{name}-deb-update-mp" |
670 | + concurrent: true |
671 | + node: deb && misc |
672 | + parameters: |
673 | + - string: |
674 | + name: CI_RESULT |
675 | + description: Result of the CI build |
676 | + - string: |
677 | + name: CI_BUILD |
678 | + description: Jenkins URL of the build |
679 | + - string: |
680 | + name: CI_BRANCH |
681 | + description: Launchpad branch that was processed |
682 | + - string: |
683 | + name: CI_MERGE_PROPOSAL |
684 | + description: Launchpad merge proposal that was processed |
685 | + - string: |
686 | + name: CI_REVISION |
687 | + description: Revision of the processed branch |
688 | + builders: |
689 | + - shell: |
690 | + !include-raw: |
691 | + - common-job-prepare.sh |
692 | + - shell: |
693 | + !include-raw-escape: |
694 | + - deb-update-mp.sh |
695 | diff --git a/tools/debbuild.sh b/tools/debbuild.sh |
696 | new file mode 100755 |
697 | index 0000000..2ede0c9 |
698 | --- /dev/null |
699 | +++ b/tools/debbuild.sh |
700 | @@ -0,0 +1,183 @@ |
701 | +#!/bin/sh |
702 | +# |
703 | +# Copyright (C) 2017 Canonical Ltd |
704 | +# |
705 | +# This program is free software: you can redistribute it and/or modify |
706 | +# it under the terms of the GNU General Public License version 3 as |
707 | +# published by the Free Software Foundation. |
708 | +# |
709 | +# This program is distributed in the hope that it will be useful, |
710 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
711 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
712 | +# GNU General Public License for more details. |
713 | +# |
714 | +# You should have received a copy of the GNU General Public License |
715 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
716 | + |
717 | +set -ex |
718 | + |
719 | +if [ "$(id -u)" -ne 0 ]; then |
720 | + echo "ERROR: You have to run this script as root!" |
721 | + exit 1 |
722 | +fi |
723 | + |
724 | +SERIES=xenial |
725 | +SOURCE_DIR= |
726 | +RESULTS_DIR= |
727 | +# Whenever you change the chroot in a way which needs a regeneration |
728 | +# on the build server bump the version here. This will tell the |
729 | +# job which updates the chroots to generate a new one. |
730 | +CHROOT_VERSION=1 |
731 | +BUILD_ARCH=amd64 |
732 | +TARGET_ARCH=amd64 |
733 | +UPDATE_CHROOT=false |
734 | +PROXY= |
735 | +SNAPCRAFT_EXTRA_ARGS= |
736 | + |
737 | +while [ -n "$1" ]; do |
738 | + case "$1" in |
739 | + --series=*) |
740 | + SERIES=${1#*=} |
741 | + shift |
742 | + ;; |
743 | + --source-dir=*) |
744 | + SOURCE_DIR=${1#*=} |
745 | + shift |
746 | + ;; |
747 | + --results-dir=*) |
748 | + RESULTS_DIR=${1#*=} |
749 | + shift |
750 | + ;; |
751 | + --arch=*) |
752 | + TARGET_ARCH=${1#*=} |
753 | + BUILD_ARCH=$TARGET_ARCH |
754 | + shift |
755 | + ;; |
756 | + --update-chroot) |
757 | + UPDATE_CHROOT=true |
758 | + shift |
759 | + ;; |
760 | + --proxy=*) |
761 | + PROXY=${1#*=} |
762 | + shift |
763 | + ;; |
764 | + *) |
765 | + echo "ERROR: Unknown options $1" |
766 | + exit 1 |
767 | + esac |
768 | +done |
769 | + |
770 | +if [ -z "$SERIES" ]; then |
771 | + echo "ERROR: No series specified" |
772 | + exit 1 |
773 | +fi |
774 | + |
775 | +CHROOT_STORE_PATH=/build/chroots |
776 | +CHROOT_TARBALL=$SERIES-$BUILD_ARCH-$CHROOT_VERSION-rootfs.tar |
777 | + |
778 | +if [ "$UPDATE_CHROOT" = true ]; then |
779 | + if [ ! -e $CHROOT_STORE_PATH/$CHROOT_TARBALL ] ; then |
780 | + mkdir -p /build/chroots |
781 | + WORKDIR=$(mktemp -d) |
782 | + mkdir -p $WORKDIR/rootfs |
783 | + |
784 | + DEBOOTSTRAP=debootstrap |
785 | + DEB_REPO_URL= |
786 | + case "$BUILD_ARCH" in |
787 | + amd64) |
788 | + DEB_REPO_URL="http://archive.ubuntu.com/ubuntu/" |
789 | + ;; |
790 | + armhf) |
791 | + DEBOOTSTRAP=qemu-debootstrap |
792 | + DEB_REPO_URL="http://ports.ubuntu.com/ubuntu-ports" |
793 | + ;; |
794 | + *) |
795 | + echo "ERROR: Unsupported architecture $BUILD_ARCH" |
796 | + exit 1 |
797 | + ;; |
798 | + esac |
799 | + |
800 | + cleanup() { |
801 | + rm -rf $WORKDIR |
802 | + } |
803 | + |
804 | + trap cleanup INT EXIT |
805 | + |
806 | + $DEBOOTSTRAP --components=main,universe --arch $BUILD_ARCH $SERIES $WORKDIR/rootfs |
807 | + cat << EOF > $WORKDIR/rootfs/etc/apt/sources.list.d/updates.list |
808 | +deb $DEB_REPO_URL $SERIES universe |
809 | +deb $DEB_REPO_URL $SERIES-updates main universe |
810 | +EOF |
811 | + cat << EOF > $WORKDIR/rootfs/setup.sh |
812 | +#!/bin/sh |
813 | +set -ex |
814 | +apt update |
815 | +apt upgrade -y |
816 | +apt install -y build-essential fakeroot |
817 | +EOF |
818 | + chmod +x $WORKDIR/rootfs/setup.sh |
819 | + sudo chroot $WORKDIR/rootfs /setup.sh |
820 | + rm $WORKDIR/rootfs/setup.sh |
821 | + |
822 | + (cd $WORKDIR/rootfs; tar cf $CHROOT_STORE_PATH/$CHROOT_TARBALL .) |
823 | + rm -rf $WORKDIR |
824 | + fi |
825 | + |
826 | + exit 0 |
827 | +fi |
828 | + |
829 | +if [ -z "$SOURCE_DIR" ]; then |
830 | + echo "ERROR: No source dir specified" |
831 | + exit 1 |
832 | +fi |
833 | + |
834 | +if [ -z "$RESULTS_DIR" ]; then |
835 | + echo "ERROR: No results dir specified" |
836 | + exit 1 |
837 | +fi |
838 | + |
839 | +BUILDDIR=$(mktemp -d) |
840 | + |
841 | +cleanup() { |
842 | + rm -rf $BUILDDIR |
843 | +} |
844 | + |
845 | +trap cleanup INT EXIT |
846 | + |
847 | +if [ ! -e $CHROOT_STORE_PATH/$CHROOT_TARBALL ] ; then |
848 | + echo "ERROR: Up to date chroot tarball doesn't exist. Please run the snap-build-update-chroot job!" |
849 | + exit 1 |
850 | +fi |
851 | + |
852 | +tar xf $CHROOT_STORE_PATH/$CHROOT_TARBALL -C $BUILDDIR |
853 | + |
854 | +cp -ra $SOURCE_DIR $BUILDDIR/src |
855 | + |
856 | +cat << EOF > $BUILDDIR/do-build.sh |
857 | +#!/bin/sh |
858 | +set -ex |
859 | +apt update |
860 | +apt upgrade -y |
861 | + |
862 | +export LC_ALL=C.UTF-8 |
863 | +export LANG=C.UTF-8 |
864 | + |
865 | +cd /src |
866 | + |
867 | +DEBCONTROL=debian/control |
868 | +PACKAGE=$(cat $DEBIANCONTROL | grep "Source:" | awk '{print $2}') |
869 | + |
870 | +# Install build dependencies |
871 | +sudo apt-get -y build-dep $PACKAGE |
872 | + |
873 | +# To access certain things we need proxy in place |
874 | +export http_proxy=$PROXY |
875 | +export https_proxy=$PROXY |
876 | + |
877 | +# Build the package |
878 | +dpkg-buildpackage -us -uc |
879 | +EOF |
880 | +chmod +x $BUILDDIR/do-build.sh |
881 | + |
882 | +sudo chroot $BUILDDIR /do-build.sh |
883 | +sudo cp $BUILDDIR/*.[dsc,deb,changes] "$RESULTS_DIR" |
PASSED: Continuous integration, rev:81e57b33d30 4d83b31b0556db0 b746cd7c9f62c4 /jenkins. canonical. com/system- enablement/ job/snappy- hwe-snaps- snap-build/ 31/ /jenkins. canonical. com/system- enablement/ job/snappy- hwe-snaps- snap-build/ ARCHITECTURE= amd64/31 /jenkins. canonical. com/system- enablement/ job/snappy- hwe-snaps- snap-build/ ARCHITECTURE= arm64/31 /jenkins. canonical. com/system- enablement/ job/snappy- hwe-snaps- snap-build/ ARCHITECTURE= armhf/31 /jenkins. canonical. com/system- enablement/ job/snappy- hwe-snaps- snap-build/ ARCHITECTURE= i386/31
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild: /jenkins. canonical. com/system- enablement/ job/snappy- hwe-snaps- snap-build/ 31/rebuild
https:/