Merge ~kzapalowicz/snappy-hwe-snaps/+git/jenkins-jobs:feature/deb-builds into ~snappy-hwe-team/snappy-hwe-snaps/+git/jenkins-jobs:master

Proposed by Konrad Zapałowicz
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)
Reviewer Review Type Date Requested Status
System Enablement Bot continuous-integration Approve
Simon Fels Needs Fixing
Review via email: mp+332172@code.launchpad.net

Description of the change

add jobs to build debian packages

To post a comment you must log in.
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)
abb3609... by =?utf-8?q?Konrad_Zapa=C5=82owicz?= <email address hidden>

tools: add script to build debian packages in a chroot

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Simon Fels (morphis) :
review: Needs Fixing
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

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)
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

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)

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

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/jobs/deb/common-job-prepare.sh b/jobs/deb/common-job-prepare.sh
0new file mode 1006440new file mode 100644
index 0000000..204a87d
--- /dev/null
+++ b/jobs/deb/common-job-prepare.sh
@@ -0,0 +1,58 @@
1#!/bin/sh -ex
2#
3# Copyright (C) 2017 Canonical Ltd
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 3 as
7# published by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17# This is a common place to be a forwarder of varibles definied in
18# the job definition. To avoid using templating in the actual job
19# shell script we have a common .sh file which does this for us.
20#
21# Whenever you need something which is suitable for multiple jobs
22# or originates from the job definition and needs to be added
23# through a template variable inside the shell script this
24# is the right place for it.
25#
26# This file will be sourced by all jobs.
27
28JENKINS_JOBS_GIT_REPO="{jobs-git-repo}"
29JENKINS_JOBS_GIT_REPO_BRANCH="{jobs-git-repo-branch}"
30
31# Ensure we have a clean and empty workspace but keep our jenkins-jobs
32# repository so we don't have to clone it again
33for f in $(ls "${{WORKSPACE}}"); do
34 if [ "${{f}}" = jenkins-jobs ]; then
35 continue
36 fi
37 rm -rf "${{WORKSPACE}}"/"${{f}}"
38done
39
40if [ -e jenkins-jobs ] ; then
41 (cd jenkins-jobs ; git clean -fdx . ; git fetch origin ; git reset --hard origin/${{JENKINS_JOBS_GIT_REPO_BRANCH}})
42else
43 git clone -b ${{JENKINS_JOBS_GIT_REPO_BRANCH}} ${{JENKINS_JOBS_GIT_REPO}}
44fi
45
46cat << EOF > $WORKSPACE/.build_env
47BOT_USERNAME={bot_username}
48LAUNCHPAD_PROJECT={launchpad_project}
49LAUNCHPAD_TEAM={launchpad_team}
50DEB_BUILD_JOB={name}-deb-build-prepare
51BUILD_SCRIPTS=$WORKSPACE/jenkins-jobs
52BUILD_ON_LAUNCHPAD={build_on_launchpad}
53AUTO_MERGE={auto_merge}
54TRIGGER_CI={trigger_ci}
55UPDATE_MPS={update_mps}
56RUN_TESTS={run_tests}
57CI_REPO=ci-build-${{CI_ID}}
58EOF
diff --git a/jobs/deb/deb-build-prepare.sh b/jobs/deb/deb-build-prepare.sh
0new file mode 10064459new file mode 100644
index 0000000..1ee6fae
--- /dev/null
+++ b/jobs/deb/deb-build-prepare.sh
@@ -0,0 +1,85 @@
1#!/bin/bash
2#
3# Copyright (C) 2017 Canonical Ltd
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 3 as
7# published by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17set -ex
18
19. "$WORKSPACE/.build_env"
20
21# CI_ID isn't specified yet when we're being called so initialize
22# it here with the same value as we do in deb-build-prepare.yaml
23if [ -z "$CI_ID" ]; then
24 CI_ID=$BUILD_ID
25fi
26
27rm -rf $WORKSPACE/src
28
29git clone --no-checkout $TARGET_GIT_REPO $WORKSPACE/src
30cd $WORKSPACE/src
31for remote in $(git branch -r | grep -v origin/master); do
32 git checkout --track $remote
33done
34
35git checkout $TARGET_GIT_REPO_BRANCH
36
37git config user.name "System Enablement CI Bot"
38git config user.email "ce-system-enablement@lists.canonical.com"
39
40if [ -n "$SOURCE_GIT_REPO" ]; then
41 git remote add other $SOURCE_GIT_REPO
42 git fetch other
43 git merge \
44 --no-ff \
45 -m "Merge remote tracking branch other/$SOURCE_GIT_REPO_BRANCH" \
46 $REVISION
47fi
48
49# Try to find the correct branch we need to build from. In the case that
50# $TARGET_GIT_REPO_BRANCH points us to an upstream component branch we
51# will take master as the next suitable candidate.
52CI_BRANCH=
53DEBIAN_DIRECTORY_PATH=
54for branch in $TARGET_GIT_REPO_BRANCH master ; do
55 git checkout $branch
56 if [ -d debian ]; then
57 DEBIAN_DIRECTORY_PATH=debian
58 fi
59
60 if [ -n "$DEBIAN_DIRECTORY_PATH" ]; then
61 CI_BRANCH=$branch
62 break
63 fi
64done
65
66if [ -z "$CI_BRANCH" ]; then
67 echo "WARNING: Can't build snap as no snapcraft.yaml exists!"
68 exit 0
69fi
70
71# Now let's setup some variables that are important for the build process
72
73REPO_NAME=$(awk -v a="$TARGET_GIT_REPO" 'BEGIN{print substr(a, index(a, "+git/") + 5)}')
74# We rely on the snapcraft.yaml to have the snap name in the first five lines
75# which is the case for all our snaps. This is a bit lazy but the best way to
76# ensure we don't fetch any other name: fields which might be present in the file.
77DEB_NAME=$(cat $DEBIAN_DIRECTORY_PATH/control | grep "^Source:" | awk '{print $2}')
78DEB_REV=$(git rev-parse --short HEAD)
79CI_REPO=ci-build-$CI_ID
80
81# Push to CI repository
82
83git remote add jenkins-ci git+ssh://$BOT_USERNAME@git.launchpad.net/~$LAUNCHPAD_TEAM/$LAUNCHPAD_PROJECT/+git/$CI_REPO
84git push jenkins-ci --all
85git push jenkins-ci --tags
diff --git a/jobs/deb/deb-build-prepare.yaml b/jobs/deb/deb-build-prepare.yaml
0new file mode 10064486new file mode 100644
index 0000000..c75f803
--- /dev/null
+++ b/jobs/deb/deb-build-prepare.yaml
@@ -0,0 +1,63 @@
1- job-template:
2 name: '{name}-deb-build-prepare'
3 project-type: freestyle
4 defaults: global
5 description: ""
6 display-name: "{name}-deb-build-prepare"
7 concurrent: true
8 node: deb && misc
9 properties:
10 - build-discarder:
11 num-to-kep: 10
12 - rebuild
13 parameters:
14 - string:
15 name: TARGET_GIT_REPO
16 default:
17 description: "Target git repository"
18 - string:
19 name: TARGET_GIT_REPO_BRANCH
20 default: master
21 description: "Branch of the target git repository to build from"
22 - string:
23 name: SERIES
24 default: xenial
25 description: "Ubuntu archive series to build for"
26 - string:
27 name: FORCE
28 default: "0"
29 description: "Set to 1 to force the build"
30 - string:
31 name: SOURCE_GIT_REPO
32 default:
33 description: "Source git repository"
34 - string:
35 name: SOURCE_GIT_REPO_BRANCH
36 default:
37 description: "Branch of the source git repository to use"
38 - string:
39 name: MERGE_PROPOSAL
40 default:
41 description: "Link to the merge proposal this build relates to"
42 - string:
43 name: REVISION
44 default:
45 description: "Git revision that is being build"
46 - string:
47 name: CLEANUP_WORKSPACE
48 default: "0"
49 description: "Cleanup the whole workspace"
50 builders:
51 - shell:
52 !include-raw:
53 - common-job-prepare.sh
54 - shell:
55 !include-raw-escape:
56 - deb-build-prepare.sh
57 - trigger-builds:
58 - project: '{name}-deb-build'
59 current-parameters: true
60 predefined-parameters: |
61 CI_ID=$BUILD_ID
62 RESULTS_ID=$BUILD_TAG
63 block: true
diff --git a/jobs/deb/deb-build-worker.sh b/jobs/deb/deb-build-worker.sh
0new file mode 10064464new file mode 100644
index 0000000..56c7481
--- /dev/null
+++ b/jobs/deb/deb-build-worker.sh
@@ -0,0 +1,57 @@
1#!/bin/sh
2#
3# Copyright (C) 2017 Canonical Ltd
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 3 as
7# published by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17set -ex
18
19. "$WORKSPACE/.build_env"
20
21rm -rf $WORKSPACE/src $WORKSPACE/results
22
23# Debian packages will be build in chroot for the host architecture using
24# bits from https://launchpad.net/jenkaas-jobs to do the job.
25
26DEBBUILD_EXTRA_ARGS=
27
28sudo $BUILD_SCRIPTS/tools/debbuild.sh \
29 --source-dir=$WORKSPACE/src \
30 --results-dir=$WORKSPACE/results \
31 --arch=$ARCHITECTURE \
32 --series=$SERIES \
33 --proxy=http://squid.internal:3128 \
34 $DEBBUILD_EXTRA_ARGS
35
36# Build is done, now copy the build artifacts to the remote location
37
38if [ -z "$REMOTE_WORKER" ]; then
39 echo "INFO: No remote worker defined, not copying artifacts to it"
40 exit 0
41fi
42
43SSH_PATH="${JENKINS_HOME}/.ssh/"
44SSH_KEY_PATH="${SSH_PATH}/git.launchpad.net/$BOT_USERNAME"
45SSH="ssh -i $SSH_KEY_PATH/id_rsa $REMOTE_USER@$REMOTE_WORKER"
46SCP="scp -i $SSH_KEY_PATH/id_rsa"
47
48REMOTE_RESULTS_BASE_DIR=/home/$REMOTE_USER/results
49
50$SSH mkdir -p $REMOTE_RESULTS_BASE_DIR/$RESULTS_ID
51$SCP $WORKSPACE/results/*.deb $REMOTE_USER@$REMOTE_WORKER:$REMOTE_RESULTS_BASE_DIR/$RESULTS_ID/
52
53# Save the id of our results so it can be used by a subsequent build
54# in a properties file which is then being read from jenkins and its
55# content passed as parameters to triggered builds.
56echo "RESULTS_ID=$RESULTS_ID" >> $WORKSPACE/build-props
57cat $WORKSPACE/build-props
diff --git a/jobs/deb/deb-build-worker.yaml b/jobs/deb/deb-build-worker.yaml
0new file mode 10064458new file mode 100644
index 0000000..18b09b8
--- /dev/null
+++ b/jobs/deb/deb-build-worker.yaml
@@ -0,0 +1,72 @@
1- job-template:
2 name: '{name}-deb-build-worker'
3 project-type: freestyle
4 defaults: global
5 description: "Build a deb on launchpad"
6 display-name: "{name}-deb-build-worker"
7 concurrent: true
8 node: deb && build
9 parameters:
10 - string:
11 name: ARCHITECTURE
12 default: amd64
13 description: Architecture to build the deb for
14 - string:
15 name: TARGET_GIT_REPO
16 default:
17 description: "Target git repository"
18 - string:
19 name: TARGET_GIT_REPO_BRANCH
20 default: master
21 description: "Branch of the target git repository to build from"
22 - string:
23 name: SERIES
24 default: xenial
25 description: "Ubuntu archive series to build for"
26 - string:
27 name: FORCE
28 default: "0"
29 description: "Set to 1 to force the build"
30 - string:
31 name: SOURCE_GIT_REPO
32 default:
33 description: "Source git repository"
34 - string:
35 name: SOURCE_GIT_REPO_BRANCH
36 default:
37 description: "Branch of the source git repository to use"
38 - string:
39 name: MERGE_PROPOSAL
40 default:
41 description: "Link to the merge proposal this build relates to"
42 - string:
43 name: REVISION
44 default:
45 description: "Git revision that is being build"
46 - string:
47 name: CLEANUP_WORKSPACE
48 default: "0"
49 description: "Cleanup the whole workspace"
50 - string:
51 name: REMOTE_WORKER
52 default: "{obj:remote_worker}"
53 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."
54 - string:
55 name: REMOTE_USER
56 default: "{obj:remote_user}"
57 description: "The remote server username used to ssh to $REMOTE_WORKER."
58 - string:
59 name: CI_ID
60 default: ''
61 description: "Numeric id which will identify the CI iteration through all downstream builds"
62 - string:
63 name: RESULTS_ID
64 default: ''
65 description: "Alphanumeric identifier used to pass build artifacts through different jobs"
66 builders:
67 - shell:
68 !include-raw:
69 - common-job-prepare.sh
70 - shell:
71 !include-raw-escape:
72 - deb-build-worker.sh
diff --git a/jobs/deb/deb-build.yaml b/jobs/deb/deb-build.yaml
0new file mode 10064473new file mode 100644
index 0000000..4a11d32
--- /dev/null
+++ b/jobs/deb/deb-build.yaml
@@ -0,0 +1,90 @@
1- job-template:
2 name: '{name}-deb-build'
3 project-type: matrix
4 defaults: global
5 description: "Build a deb with subsequent test execution"
6 display-name: "{name}-deb-build"
7 concurrent: true
8 sequential: false
9 node: monitor
10 axes:
11 - axis:
12 type: user-defined
13 name: ARCHITECTURE
14 values: '{obj:build_architectures}'
15 parameters:
16 - string:
17 name: TARGET_GIT_REPO
18 default:
19 description: "Target git repository"
20 - string:
21 name: TARGET_GIT_REPO_BRANCH
22 default: master
23 description: "Branch of the target git repository to build from"
24 - string:
25 name: SERIES
26 default: xenial
27 description: "Ubuntu archive series to build for"
28 - string:
29 name: FORCE
30 default: "0"
31 description: "Set to 1 to force the build"
32 - string:
33 name: SOURCE_GIT_REPO
34 default:
35 description: "Source git repository"
36 - string:
37 name: SOURCE_GIT_REPO_BRANCH
38 default:
39 description: "Branch of the source git repository to use"
40 - string:
41 name: MERGE_PROPOSAL
42 default:
43 description: "Link to the merge proposal this build relates to"
44 - string:
45 name: REVISION
46 default:
47 description: "Cleanup the whole workspace"
48 - string:
49 name: CLEANUP_WORKSPACE
50 default: "0"
51 description: "Cleanup the whole workspace"
52 - string:
53 name: CI_ID
54 default: ''
55 description: "Numeric id which will identify the CI iteration through all downstream builds"
56 builders:
57 - trigger-builds:
58 - project: '{name}-deb-build-worker'
59 current-parameters: true
60 predefined-parameters: |
61 ARCHITECTURE=$ARCHITECTURE
62 block: true
63 - project: '{name}-deb-docs'
64 current-parameters: true
65 block: true
66 - project: '{name}-deb-cleanup'
67 current-parameters: true
68 publishers:
69 - archive:
70 artifacts: '**/*.deb'
71 latest-only: false
72 allow-empty: true
73 fingerprint: false
74 - trigger-parameterized-builds:
75 - project: '{name}-deb-update-mp'
76 condition: "SUCCESS"
77 predefined-parameters: |
78 CI_RESULT=PASSED
79 CI_BUILD=${{BUILD_URL}}
80 CI_BRANCH="${{SOURCE_GIT_REPO_BRANCH}}@${{SOURCE_GIT_REPO}}"
81 CI_MERGE_PROPOSAL=${{MERGE_PROPOSAL}}
82 CI_REVISION=${{REVISION}}
83 - project: '{name}-deb-update-mp'
84 condition: "UNSTABLE_OR_WORSE"
85 predefined-parameters: |
86 CI_RESULT=FAILED
87 CI_BUILD=${{BUILD_URL}}
88 CI_BRANCH="${{SOURCE_GIT_REPO_BRANCH}}@${{SOURCE_GIT_REPO}}"
89 CI_MERGE_PROPOSAL=${{MERGE_PROPOSAL}}
90 CI_REVISION=${{REVISION}}
diff --git a/jobs/deb/deb-cleanup.sh b/jobs/deb/deb-cleanup.sh
0new file mode 10064491new file mode 100644
index 0000000..bf0e03c
--- /dev/null
+++ b/jobs/deb/deb-cleanup.sh
@@ -0,0 +1,38 @@
1#!/bin/sh
2#
3# Copyright (C) 2017 Canonical Ltd
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 3 as
7# published by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17set -x
18
19. "$WORKSPACE/.build_env"
20
21# Delete auxiliary repo used in the build
22$BUILD_SCRIPTS/tools/delete-ci-repo.py \
23 --git-repo=https://git.launchpad.net/~$LAUNCHPAD_TEAM/$LAUNCHPAD_PROJECT/+git/$CI_REPO
24
25if [ -z "$REMOTE_WORKER" ]; then
26 echo "INFO: No remote system defined"
27 exit 0
28fi
29
30SSH_PATH="${JENKINS_HOME}/.ssh/"
31SSH_KEY_PATH="${SSH_PATH}/git.launchpad.net/$BOT_USERNAME"
32SSH="ssh -i $SSH_KEY_PATH/id_rsa $REMOTE_USER@$REMOTE_WORKER"
33REMOTE_RESULTS_BASE_DIR=/home/$REMOTE_USER/results
34
35$SSH rm -rf $REMOTE_RESULTS_BASE_DIR/$RESULTS_ID
36
37# Now remove any container that might have been left behind...
38$SSH sudo docker rm \$\(sudo docker ps -q --filter=status=exited --filter=ancestor=snap-spread-tests\) || true
diff --git a/jobs/deb/deb-cleanup.yaml b/jobs/deb/deb-cleanup.yaml
0new file mode 10064439new file mode 100644
index 0000000..1b6480e
--- /dev/null
+++ b/jobs/deb/deb-cleanup.yaml
@@ -0,0 +1,32 @@
1- job-template:
2 name: '{name}-deb-cleanup'
3 project-type: freestyle
4 defaults: global
5 description: "Cleanup artifacts left over from a deb build"
6 display-name: "{name}-deb-cleanup"
7 concurrent: true
8 node: deb && build
9 parameters:
10 - string:
11 name: CI_ID
12 default: ''
13 description: "Numeric id which will identify the CI iteration through all downstream builds"
14 - string:
15 name: RESULTS_ID
16 default: ""
17 description: "Alphanumeric Id of the results being staged on the remote worker"
18 - string:
19 name: REMOTE_WORKER
20 default: "{obj:remote_worker}"
21 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."
22 - string:
23 name: REMOTE_USER
24 default: "{obj:remote_user}"
25 description: "The remote server username used to ssh to $REMOTE_WORKER."
26 builders:
27 - shell:
28 !include-raw:
29 - common-job-prepare.sh
30 - shell:
31 !include-raw-escape:
32 - deb-cleanup.sh
diff --git a/jobs/deb/deb-project-jobs.yaml b/jobs/deb/deb-project-jobs.yaml
0new file mode 10064433new file mode 100644
index 0000000..fbcef68
--- /dev/null
+++ b/jobs/deb/deb-project-jobs.yaml
@@ -0,0 +1,9 @@
1- job-group:
2 name: deb-project-jobs
3 jobs:
4 - '{name}-deb-build-worker'
5 - '{name}-deb-build'
6 - '{name}-deb-build-prepare'
7 - '{name}-deb-cleanup'
8 - '{name}-deb-trigger-ci'
9 - '{name}-deb-update-mp'
diff --git a/jobs/deb/deb-trigger-ci.sh b/jobs/deb/deb-trigger-ci.sh
0new file mode 10064410new file mode 100644
index 0000000..5430189
--- /dev/null
+++ b/jobs/deb/deb-trigger-ci.sh
@@ -0,0 +1,29 @@
1#!/bin/bash
2#
3# Copyright (C) 2016 Canonical Ltd
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 3 as
7# published by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17set -ex
18
19. "$WORKSPACE/.build_env"
20
21if [ "$TRIGGER_CI" = False ]; then
22 echo "WARNING: CI is disabled"
23 exit 0
24fi
25
26exec "$BUILD_SCRIPTS"/tools/trigger-ci.py \
27 -p "$LAUNCHPAD_PROJECT" \
28 -j "$DEB_BUILD_JOB" \
29 -t "$LAUNCHPAD_TEAM"
diff --git a/jobs/deb/deb-trigger-ci.yaml b/jobs/deb/deb-trigger-ci.yaml
0new file mode 10064430new file mode 100644
index 0000000..03d71ac
--- /dev/null
+++ b/jobs/deb/deb-trigger-ci.yaml
@@ -0,0 +1,22 @@
1- job-template:
2 name: '{name}-deb-trigger-ci'
3 project-type: freestyle
4 defaults: global
5 description: "Monitor Launchpad for new merge proposals"
6 display-name: "{name}-deb-trigger-ci"
7 concurrent: true
8 node: deb && misc
9 triggers:
10 - timed: # every five minutes
11 H/5 * * * *
12 properties:
13 - build-discarder:
14 num-to-keep: 10
15 - rebuild
16 builders:
17 - shell:
18 !include-raw:
19 - common-job-prepare.sh
20 - shell:
21 !include-raw-escape:
22 - deb-trigger-ci.sh
diff --git a/jobs/deb/deb-update-mp.sh b/jobs/deb/deb-update-mp.sh
0new file mode 10064423new file mode 100644
index 0000000..e70e35c
--- /dev/null
+++ b/jobs/deb/deb-update-mp.sh
@@ -0,0 +1,30 @@
1#!/bin/sh
2#
3# Copyright (C) 2017 Canonical Ltd
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 3 as
7# published by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17set -ex
18
19. "$WORKSPACE/.build_env"
20
21if [ "$UPDATE_MPS" = False ]; then
22 echo "WARNING: MP updates are disabled"
23 exit 0
24fi
25
26exec $BUILD_SCRIPTS/tools/vote-on-merge-proposal.py \
27 -s $CI_RESULT \
28 -u $CI_BUILD \
29 -r $CI_REVISION \
30 -p $CI_MERGE_PROPOSAL
diff --git a/jobs/deb/deb-update-mp.yaml b/jobs/deb/deb-update-mp.yaml
0new file mode 10064431new file mode 100644
index 0000000..6b26001
--- /dev/null
+++ b/jobs/deb/deb-update-mp.yaml
@@ -0,0 +1,31 @@
1- job-template:
2 name: '{name}-deb-update-mp'
3 project-type: freestyle
4 defaults: global
5 description: "Update given merge-proposal with the result of the build"
6 display-name: "{name}-deb-update-mp"
7 concurrent: true
8 node: deb && misc
9 parameters:
10 - string:
11 name: CI_RESULT
12 description: Result of the CI build
13 - string:
14 name: CI_BUILD
15 description: Jenkins URL of the build
16 - string:
17 name: CI_BRANCH
18 description: Launchpad branch that was processed
19 - string:
20 name: CI_MERGE_PROPOSAL
21 description: Launchpad merge proposal that was processed
22 - string:
23 name: CI_REVISION
24 description: Revision of the processed branch
25 builders:
26 - shell:
27 !include-raw:
28 - common-job-prepare.sh
29 - shell:
30 !include-raw-escape:
31 - deb-update-mp.sh
diff --git a/tools/debbuild.sh b/tools/debbuild.sh
0new file mode 10075532new file mode 100755
index 0000000..2ede0c9
--- /dev/null
+++ b/tools/debbuild.sh
@@ -0,0 +1,183 @@
1#!/bin/sh
2#
3# Copyright (C) 2017 Canonical Ltd
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 3 as
7# published by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17set -ex
18
19if [ "$(id -u)" -ne 0 ]; then
20 echo "ERROR: You have to run this script as root!"
21 exit 1
22fi
23
24SERIES=xenial
25SOURCE_DIR=
26RESULTS_DIR=
27# Whenever you change the chroot in a way which needs a regeneration
28# on the build server bump the version here. This will tell the
29# job which updates the chroots to generate a new one.
30CHROOT_VERSION=1
31BUILD_ARCH=amd64
32TARGET_ARCH=amd64
33UPDATE_CHROOT=false
34PROXY=
35SNAPCRAFT_EXTRA_ARGS=
36
37while [ -n "$1" ]; do
38 case "$1" in
39 --series=*)
40 SERIES=${1#*=}
41 shift
42 ;;
43 --source-dir=*)
44 SOURCE_DIR=${1#*=}
45 shift
46 ;;
47 --results-dir=*)
48 RESULTS_DIR=${1#*=}
49 shift
50 ;;
51 --arch=*)
52 TARGET_ARCH=${1#*=}
53 BUILD_ARCH=$TARGET_ARCH
54 shift
55 ;;
56 --update-chroot)
57 UPDATE_CHROOT=true
58 shift
59 ;;
60 --proxy=*)
61 PROXY=${1#*=}
62 shift
63 ;;
64 *)
65 echo "ERROR: Unknown options $1"
66 exit 1
67 esac
68done
69
70if [ -z "$SERIES" ]; then
71 echo "ERROR: No series specified"
72 exit 1
73fi
74
75CHROOT_STORE_PATH=/build/chroots
76CHROOT_TARBALL=$SERIES-$BUILD_ARCH-$CHROOT_VERSION-rootfs.tar
77
78if [ "$UPDATE_CHROOT" = true ]; then
79 if [ ! -e $CHROOT_STORE_PATH/$CHROOT_TARBALL ] ; then
80 mkdir -p /build/chroots
81 WORKDIR=$(mktemp -d)
82 mkdir -p $WORKDIR/rootfs
83
84 DEBOOTSTRAP=debootstrap
85 DEB_REPO_URL=
86 case "$BUILD_ARCH" in
87 amd64)
88 DEB_REPO_URL="http://archive.ubuntu.com/ubuntu/"
89 ;;
90 armhf)
91 DEBOOTSTRAP=qemu-debootstrap
92 DEB_REPO_URL="http://ports.ubuntu.com/ubuntu-ports"
93 ;;
94 *)
95 echo "ERROR: Unsupported architecture $BUILD_ARCH"
96 exit 1
97 ;;
98 esac
99
100 cleanup() {
101 rm -rf $WORKDIR
102 }
103
104 trap cleanup INT EXIT
105
106 $DEBOOTSTRAP --components=main,universe --arch $BUILD_ARCH $SERIES $WORKDIR/rootfs
107 cat << EOF > $WORKDIR/rootfs/etc/apt/sources.list.d/updates.list
108deb $DEB_REPO_URL $SERIES universe
109deb $DEB_REPO_URL $SERIES-updates main universe
110EOF
111 cat << EOF > $WORKDIR/rootfs/setup.sh
112#!/bin/sh
113set -ex
114apt update
115apt upgrade -y
116apt install -y build-essential fakeroot
117EOF
118 chmod +x $WORKDIR/rootfs/setup.sh
119 sudo chroot $WORKDIR/rootfs /setup.sh
120 rm $WORKDIR/rootfs/setup.sh
121
122 (cd $WORKDIR/rootfs; tar cf $CHROOT_STORE_PATH/$CHROOT_TARBALL .)
123 rm -rf $WORKDIR
124 fi
125
126 exit 0
127fi
128
129if [ -z "$SOURCE_DIR" ]; then
130 echo "ERROR: No source dir specified"
131 exit 1
132fi
133
134if [ -z "$RESULTS_DIR" ]; then
135 echo "ERROR: No results dir specified"
136 exit 1
137fi
138
139BUILDDIR=$(mktemp -d)
140
141cleanup() {
142 rm -rf $BUILDDIR
143}
144
145trap cleanup INT EXIT
146
147if [ ! -e $CHROOT_STORE_PATH/$CHROOT_TARBALL ] ; then
148 echo "ERROR: Up to date chroot tarball doesn't exist. Please run the snap-build-update-chroot job!"
149 exit 1
150fi
151
152tar xf $CHROOT_STORE_PATH/$CHROOT_TARBALL -C $BUILDDIR
153
154cp -ra $SOURCE_DIR $BUILDDIR/src
155
156cat << EOF > $BUILDDIR/do-build.sh
157#!/bin/sh
158set -ex
159apt update
160apt upgrade -y
161
162export LC_ALL=C.UTF-8
163export LANG=C.UTF-8
164
165cd /src
166
167DEBCONTROL=debian/control
168PACKAGE=$(cat $DEBIANCONTROL | grep "Source:" | awk '{print $2}')
169
170# Install build dependencies
171sudo apt-get -y build-dep $PACKAGE
172
173# To access certain things we need proxy in place
174export http_proxy=$PROXY
175export https_proxy=$PROXY
176
177# Build the package
178dpkg-buildpackage -us -uc
179EOF
180chmod +x $BUILDDIR/do-build.sh
181
182sudo chroot $BUILDDIR /do-build.sh
183sudo cp $BUILDDIR/*.[dsc,deb,changes] "$RESULTS_DIR"

Subscribers

People subscribed via source and target branches