Merge ~alfonsosanchezbeato/snappy-hwe-snaps/+git/build-scripts:build-from-master into ~snappy-hwe-team/snappy-hwe-snaps/+git/build-scripts:master

Proposed by Alfonso Sanchez-Beato
Status: Merged
Approved by: Simon Fels
Approved revision: 24d4ea9b0740f294e2d446a24f27d0c63ccabe9f
Merged at revision: 5582cd48aeef69a0cb6eed752360d62faf3c4279
Proposed branch: ~alfonsosanchezbeato/snappy-hwe-snaps/+git/build-scripts:build-from-master
Merge into: ~snappy-hwe-team/snappy-hwe-snaps/+git/build-scripts:master
Diff against target: 105 lines (+63/-8)
2 files modified
jobs/generic-build-snap-worker (+18/-8)
scripts/delete-ci-repo.py (+45/-0)
Reviewer Review Type Date Requested Status
Simon Fels Approve
Jim Hodapp (community) Approve
System Enablement Bot continuous-integration Approve
Review via email: mp+319169@code.launchpad.net

Commit message

Always build from master the branch.

Description of the change

Always build from master the branch.

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

Comments addressed.

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

LGTM

review: Approve
Revision history for this message
Simon Fels (morphis) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/jobs/generic-build-snap-worker b/jobs/generic-build-snap-worker
2index d0008df..074318d 100755
3--- a/jobs/generic-build-snap-worker
4+++ b/jobs/generic-build-snap-worker
5@@ -33,17 +33,27 @@ if [ -n "$SOURCE_GIT_REPO" ]; then
6 $REVISION
7 fi
8
9+# Always build against master so all tests are performed
10+CI_BRANCH=master
11+
12+git checkout $CI_BRANCH
13 if [ ! -e snapcraft.yaml ] ; then
14 echo "WARNING: Can't build snap as no snapcraft.yaml exists!"
15 exit 0
16 fi
17
18+REPO_NAME=$(awk -v a="$TARGET_GIT_REPO" 'BEGIN{print substr(a, index(a, "+git/") + 5)}')
19 SNAP_NAME=$(grep "name:" snapcraft.yaml | awk '{print $2}')
20 SNAP_REV=$(git rev-parse --short HEAD)
21-CI_BRANCH=build/$SNAP_NAME-$BUILD_ID-$SNAP_REV
22-git checkout -b $CI_BRANCH
23-git remote add jenkins-ci git+ssh://system-enablement-ci-bot@git.launchpad.net/~snappy-hwe-team/snappy-hwe-snaps/+git/jenkins-ci-builds
24-git push jenkins-ci $CI_BRANCH
25+CI_REPO=$REPO_NAME-$BUILD_ID-$SNAP_REV
26+
27+sed -i "s/~snappy-hwe-team\/snappy-hwe-snaps\/+git\/$REPO_NAME/~snappy-hwe-team\/snappy-hwe-snaps\/+git\/$CI_REPO/g" snapcraft.yaml
28+git add snapcraft.yaml
29+git commit -m "jenkins-ci: Fix paths"
30+
31+git remote add jenkins-ci git+ssh://system-enablement-ci-bot@git.launchpad.net/~snappy-hwe-team/snappy-hwe-snaps/+git/$CI_REPO
32+git push jenkins-ci --all
33+git push jenkins-ci --tags
34
35 EXTRA_ARGS=
36 if [ -n "$ARCHITECTURES" ]; then
37@@ -52,13 +62,13 @@ fi
38
39 $WORKSPACE/build-scripts/scripts/trigger-lp-build.py \
40 -s $SNAP_NAME -n \
41- --git-repo=https://git.launchpad.net/~snappy-hwe-team/snappy-hwe-snaps/+git/jenkins-ci-builds \
42+ --git-repo=https://git.launchpad.net/~snappy-hwe-team/snappy-hwe-snaps/+git/$CI_REPO \
43 --git-repo-branch=$CI_BRANCH \
44 --results-dir=$WORKSPACE/results \
45 $EXTRA_ARGS
46-# When build has finished (regardless of its result) we remove our CI branch
47-# to keep the CI repository clean.
48-git push jenkins-ci :$CI_BRANCH
49+# When build has finished remove the repository we just created
50+$WORKSPACE/build-scripts/scripts/delete-ci-repo.py \
51+ --git-repo=https://git.launchpad.net/~snappy-hwe-team/snappy-hwe-snaps/+git/$CI_REPO
52 if [ $? -ne 0 ]; then
53 exit 1
54 fi
55diff --git a/scripts/delete-ci-repo.py b/scripts/delete-ci-repo.py
56new file mode 100755
57index 0000000..35c762d
58--- /dev/null
59+++ b/scripts/delete-ci-repo.py
60@@ -0,0 +1,45 @@
61+#!/usr/bin/env python
62+#
63+# Copyright (C) 2017 Canonical Ltd
64+#
65+# This program is free software: you can redistribute it and/or modify
66+# it under the terms of the GNU General Public License version 3 as
67+# published by the Free Software Foundation.
68+#
69+# This program is distributed in the hope that it will be useful,
70+# but WITHOUT ANY WARRANTY; without even the implied warranty of
71+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
72+# GNU General Public License for more details.
73+#
74+# You should have received a copy of the GNU General Public License
75+# along with this program. If not, see <http://www.gnu.org/licenses/>.
76+
77+from launchpadlib.launchpad import Launchpad
78+
79+from argparse import ArgumentParser
80+
81+import se_utils
82+
83+print("Running delete-ci-repo")
84+
85+parser = ArgumentParser(description="Delete a git repository stored in launchpad")
86+parser.add_argument('--git-repo', help="Git repository to be deleted")
87+
88+args = vars(parser.parse_args())
89+
90+git_repo = args['git_repo']
91+ind = git_repo.find('~')
92+if ind == -1:
93+ print("Bad git repo {}".format(git_repo))
94+ exit(1)
95+
96+lp_repo = git_repo[ind:]
97+
98+lp_app = se_utils.get_config_option("lp_app")
99+lp_env = se_utils.get_config_option("lp_env")
100+credential_store_path = se_utils.get_config_option('credential_store_path')
101+launchpad = se_utils.get_launchpad(None, credential_store_path, lp_app, lp_env)
102+
103+repo = launchpad.git_repositories.getByPath(path=lp_repo)
104+print("Removing {}".format(lp_repo))
105+repo.lp_delete()

Subscribers

People subscribed via source and target branches