Merge ~morphis/snappy-hwe-snaps/+git/jenkins-jobs:no-ci-branch-in-prepare into ~snappy-hwe-team/snappy-hwe-snaps/+git/jenkins-jobs:master

Proposed by Simon Fels
Status: Merged
Approved by: Alfonso Sanchez-Beato
Approved revision: 89221dc66e2a6c26cb79e68e98d653b3717fc06d
Merged at revision: b20b26ad16718ceea009a9099fdbf30d9b984782
Proposed branch: ~morphis/snappy-hwe-snaps/+git/jenkins-jobs:no-ci-branch-in-prepare
Merge into: ~snappy-hwe-team/snappy-hwe-snaps/+git/jenkins-jobs:master
Diff against target: 47 lines (+6/-15)
1 file modified
jobs/snap/snap-build-prepare.sh (+6/-15)
Reviewer Review Type Date Requested Status
Simon Fels continuous-integration Approve
Alfonso Sanchez-Beato Approve
System Enablement Bot continuous-integration Needs Fixing
Review via email: mp+332342@code.launchpad.net

Description of the change

jobs/snap: don't require a branch with a snapcraft.yaml

To post a comment you must log in.
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) :
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

LGTM

review: Approve
Revision history for this message
Simon Fels (morphis) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/jobs/snap/snap-build-prepare.sh b/jobs/snap/snap-build-prepare.sh
2index 77940d1..7639530 100644
3--- a/jobs/snap/snap-build-prepare.sh
4+++ b/jobs/snap/snap-build-prepare.sh
5@@ -49,7 +49,6 @@ fi
6 # Try to find the correct branch we need to build from. In the case that
7 # $TARGET_GIT_REPO_BRANCH points us to an upstream component branch we
8 # will take master as the next suitable candidate.
9-CI_BRANCH=
10 SNAPCRAFT_YAML_PATH=
11 for branch in $TARGET_GIT_REPO_BRANCH master ; do
12 git checkout $branch
13@@ -60,28 +59,20 @@ for branch in $TARGET_GIT_REPO_BRANCH master ; do
14 fi
15
16 if [ -n "$SNAPCRAFT_YAML_PATH" ]; then
17- CI_BRANCH=$branch
18 break
19 fi
20 done
21
22-if [ -z "$CI_BRANCH" ]; then
23- echo "WARNING: Can't build snap as no snapcraft.yaml exists!"
24- exit 0
25-fi
26-
27 REPO_NAME=$(awk -v a="$TARGET_GIT_REPO" 'BEGIN{print substr(a, index(a, "+git/") + 5)}')
28-# We rely on the snapcraft.yaml to have the snap name in the first five lines
29-# which is the case for all our snaps. This is a bit lazy but the best way to
30-# ensure we don't fetch any other name: fields which might be present in the file.
31-SNAP_NAME=$(cat $SNAPCRAFT_YAML_PATH | grep -v ^\# | head -n 5 | grep "^name:" | awk '{print $2}')
32 SNAP_REV=$(git rev-parse --short HEAD)
33 CI_REPO=ci-build-$CI_ID
34
35-sed -i "s/~$LAUNCHPAD_TEAM\/$LAUNCHPAD_PROJECT\/+git\/$REPO_NAME/~$LAUNCHPAD_TEAM\/$LAUNCHPAD_PROJECT\/+git\/$CI_REPO/g" \
36- $SNAPCRAFT_YAML_PATH
37-git add snapcraft.yaml
38-git commit -m "Update snapcraft.yaml to build from right repository"
39+if [ -n "$SNAPCRAFT_YAML_PATH" ]; then
40+ sed -i "s/~$LAUNCHPAD_TEAM\/$LAUNCHPAD_PROJECT\/+git\/$REPO_NAME/~$LAUNCHPAD_TEAM\/$LAUNCHPAD_PROJECT\/+git\/$CI_REPO/g" \
41+ $SNAPCRAFT_YAML_PATH
42+ git add snapcraft.yaml
43+ git commit -m "Update snapcraft.yaml to build from right repository"
44+fi
45
46 git remote add jenkins-ci git+ssh://$BOT_USERNAME@git.launchpad.net/~$LAUNCHPAD_TEAM/$LAUNCHPAD_PROJECT/+git/$CI_REPO
47 git push jenkins-ci --all

Subscribers

People subscribed via source and target branches

to all changes: