Merge ~morphis/snappy-hwe-snaps/+git/jenkins-jobs:select-snapcraft-yaml-in-worker into ~snappy-hwe-team/snappy-hwe-snaps/+git/jenkins-jobs:master

Proposed by Simon Fels
Status: Merged
Approved by: Alfonso Sanchez-Beato
Approved revision: 481615fc5c9049d56ff24f909c5ce3c819b83095
Merged at revision: d337273f5452e6bb8a2e78c001450978e9643083
Proposed branch: ~morphis/snappy-hwe-snaps/+git/jenkins-jobs:select-snapcraft-yaml-in-worker
Merge into: ~snappy-hwe-team/snappy-hwe-snaps/+git/jenkins-jobs:master
Diff against target: 162 lines (+63/-28)
4 files modified
jobs/snap/snap-build-prepare.yaml (+30/-0)
jobs/snap/snap-build-worker.sh (+30/-4)
jobs/snap/snap-build.yaml (+1/-22)
jobs/snap/snap-test.sh (+2/-2)
Reviewer Review Type Date Requested Status
System Enablement Bot continuous-integration Approve
Alfonso Sanchez-Beato Approve
Review via email: mp+332396@code.launchpad.net

Description of the change

jobs/snap: select correct CI branch and snapcraft.yaml in the worker job
jobs/snap: prefer git:// over https://
jobs/snap: execute docs and cleanup build as part of the -prepare job

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

LGTM

review: Approve
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
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.yaml b/jobs/snap/snap-build-prepare.yaml
2index 49c504e..63cc511 100644
3--- a/jobs/snap/snap-build-prepare.yaml
4+++ b/jobs/snap/snap-build-prepare.yaml
5@@ -61,3 +61,33 @@
6 CI_ID=$BUILD_ID
7 RESULTS_ID=$BUILD_TAG
8 block: true
9+ - project: '{name}-snap-docs'
10+ current-parameters: true
11+ block: true
12+ predefined-parameters: |
13+ ARCHITECTURE=$ARCHITECTURE
14+ block: true
15+ - project: '{name}-snap-cleanup'
16+ current-parameters: true
17+ predefined-parameters: |
18+ CI_ID=$BUILD_ID
19+ RESULTS_ID=$BUILD_TAG
20+ block: true
21+ publishers:
22+ - trigger-parameterized-builds:
23+ - project: '{name}-snap-update-mp'
24+ condition: "SUCCESS"
25+ predefined-parameters: |
26+ CI_RESULT=PASSED
27+ CI_BUILD=${{BUILD_URL}}
28+ CI_BRANCH="${{SOURCE_GIT_REPO_BRANCH}}@${{SOURCE_GIT_REPO}}"
29+ CI_MERGE_PROPOSAL=${{MERGE_PROPOSAL}}
30+ CI_REVISION=${{REVISION}}
31+ - project: '{name}-snap-update-mp'
32+ condition: "UNSTABLE_OR_WORSE"
33+ predefined-parameters: |
34+ CI_RESULT=FAILED
35+ CI_BUILD=${{BUILD_URL}}
36+ CI_BRANCH="${{SOURCE_GIT_REPO_BRANCH}}@${{SOURCE_GIT_REPO}}"
37+ CI_MERGE_PROPOSAL=${{MERGE_PROPOSAL}}
38+ CI_REVISION=${{REVISION}}
39diff --git a/jobs/snap/snap-build-worker.sh b/jobs/snap/snap-build-worker.sh
40index b654b48..e3018c3 100644
41--- a/jobs/snap/snap-build-worker.sh
42+++ b/jobs/snap/snap-build-worker.sh
43@@ -20,10 +20,31 @@ set -ex
44
45 rm -rf $WORKSPACE/src $WORKSPACE/results
46
47-git clone git+ssh://$BOT_USERNAME@git.launchpad.net/~$LAUNCHPAD_TEAM/$LAUNCHPAD_PROJECT/+git/$CI_REPO $WORKSPACE/src
48+CI_BRANCH=$TARGET_GIT_REPO_BRANCH
49+
50+git clone -b $CI_BRANCH git+ssh://$BOT_USERNAME@git.launchpad.net/~$LAUNCHPAD_TEAM/$LAUNCHPAD_PROJECT/+git/$CI_REPO $WORKSPACE/src
51+
52+# Try to find the correct branch we need to build from. In the case that
53+# $TARGET_GIT_REPO_BRANCH points us to an upstream component branch we
54+# will take master as the next suitable candidate.
55+cd $WORKSPACE/src
56+SNAPCRAFT_YAML_PATH=
57+for branch in $CI_BRANCH master ; do
58+ git checkout $branch
59+ if [ -e "$WORKSPACE/src/snapcraft.yaml" ]; then
60+ SNAPCRAFT_YAML_PATH="$WORKSPACE/src/snapcraft.yaml"
61+ elif [ -e "$WORKSPACE/src/snap/snapcraft.yaml" ]; then
62+ SNAPCRAFT_YAML_PATH="$WORKSPACE/src/snap/snapcraft.yaml"
63+ fi
64+
65+ if [ -n "$SNAPCRAFT_YAML_PATH" ]; then
66+ CI_BRANCH=$branch
67+ break
68+ fi
69+done
70
71-if [ ! -e "$WORKSPACE/src/snapcraft.yaml" ] && [ ! -e "$WORKSPACE/src/snap/snapcraft.yaml" ] ; then
72- echo "WARNING: No snapcraft build configuration available"
73+if [ -z "$SNAPCRAFT_YAML_PATH" ]; then
74+ echo "WARNING: No snapcraft.yaml found. Not trying to build anything"
75 exit 0
76 fi
77
78@@ -51,6 +72,11 @@ if [ -e $CI_OVERRIDES_PATH ]; then
79 fi
80 fi
81
82+# We rely on the snapcraft.yaml to have the snap name in the first five lines
83+# which is the case for all our snaps. This is a bit lazy but the best way to
84+# ensure we don't fetch any other name: fields which might be present in the file.
85+SNAP_NAME=$(cat $SNAPCRAFT_YAML_PATH | grep -v ^\# | head -n 5 | grep "^name:" | awk '{print $2}')
86+
87 if [ "$BUILD_ON_LAUNCHPAD" = False ]; then
88 SNAPBUILD_EXTRA_ARGS=
89 SNAP_TYPE=$($BUILD_SCRIPTS/tools/shyaml get-value type < $SNAPCRAFT_YAML_PATH || echo app)
90@@ -79,7 +105,7 @@ else
91
92 $BUILD_SCRIPTS/tools/trigger-lp-build.py \
93 -s $SNAP_NAME -n \
94- --git-repo=https://git.launchpad.net/~$LAUNCHPAD_TEAM/$LAUNCHPAD_PROJECT/+git/$CI_REPO \
95+ --git-repo=git://git.launchpad.net/~$LAUNCHPAD_TEAM/$LAUNCHPAD_PROJECT/+git/$CI_REPO \
96 --git-repo-branch=$CI_BRANCH \
97 --results-dir=$WORKSPACE/results \
98 $EXTRA_ARGS
99diff --git a/jobs/snap/snap-build.yaml b/jobs/snap/snap-build.yaml
100index 3aa338b..6cf7164 100644
101--- a/jobs/snap/snap-build.yaml
102+++ b/jobs/snap/snap-build.yaml
103@@ -60,36 +60,15 @@
104 predefined-parameters: |
105 ARCHITECTURE=$ARCHITECTURE
106 block: true
107- - project: '{name}-snap-docs'
108- current-parameters: true
109- block: true
110 - project: '{name}-snap-test'
111 current-parameters: true
112 predefined-parameters: |
113 ARCHITECTURE=$ARCHITECTURE
114+ CI_BRANCH=$TARGET_GIT_REPO_BRANCH
115 block: true
116- - project: '{name}-snap-cleanup'
117- current-parameters: true
118 publishers:
119 - archive:
120 artifacts: '**/*.snap'
121 latest-only: false
122 allow-empty: true
123 fingerprint: false
124- - trigger-parameterized-builds:
125- - project: '{name}-snap-update-mp'
126- condition: "SUCCESS"
127- predefined-parameters: |
128- CI_RESULT=PASSED
129- CI_BUILD=${{BUILD_URL}}
130- CI_BRANCH="${{SOURCE_GIT_REPO_BRANCH}}@${{SOURCE_GIT_REPO}}"
131- CI_MERGE_PROPOSAL=${{MERGE_PROPOSAL}}
132- CI_REVISION=${{REVISION}}
133- - project: '{name}-snap-update-mp'
134- condition: "UNSTABLE_OR_WORSE"
135- predefined-parameters: |
136- CI_RESULT=FAILED
137- CI_BUILD=${{BUILD_URL}}
138- CI_BRANCH="${{SOURCE_GIT_REPO_BRANCH}}@${{SOURCE_GIT_REPO}}"
139- CI_MERGE_PROPOSAL=${{MERGE_PROPOSAL}}
140- CI_REVISION=${{REVISION}}
141diff --git a/jobs/snap/snap-test.sh b/jobs/snap/snap-test.sh
142index 66876ed..5e68a94 100644
143--- a/jobs/snap/snap-test.sh
144+++ b/jobs/snap/snap-test.sh
145@@ -39,7 +39,7 @@ REMOTE_RESULTS_BASE_DIR=/home/$REMOTE_USER/results
146
147 tmp_srcdir=$(mktemp -d)
148 CI_REPO="ci-build-$CI_ID"
149-git clone --depth 1 -b $CI_BRANCH https://git.launchpad.net/~$LAUNCHPAD_TEAM/$LAUNCHPAD_PROJECT/+git/$CI_REPO
150+git clone --depth 1 -b $CI_BRANCH git://git.launchpad.net/~$LAUNCHPAD_TEAM/$LAUNCHPAD_PROJECT/+git/$CI_REPO $tmp_srcdir/src
151 cd $tmp_srcdir/src
152
153 # Components have the ability to disable CI tests if they can't provide any.
154@@ -83,7 +83,7 @@ go build github.com/snapcore/spread/cmd/spread
155 mkdir /build/bin
156 cp spread /build/bin
157
158-git clone --depth 1 -b $CI_BRANCH https://git.launchpad.net/~$LAUNCHPAD_TEAM/$LAUNCHPAD_PROJECT/+git/$CI_REPO /build/src
159+git clone --depth 1 -b $CI_BRANCH git://git.launchpad.net/~$LAUNCHPAD_TEAM/$LAUNCHPAD_PROJECT/+git/$CI_REPO /build/src
160 cd /build/src
161
162 # Copy any stage results from previous generic-build-snap-worker builds

Subscribers

People subscribed via source and target branches

to all changes: