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
diff --git a/jobs/snap/snap-build-prepare.yaml b/jobs/snap/snap-build-prepare.yaml
index 49c504e..63cc511 100644
--- a/jobs/snap/snap-build-prepare.yaml
+++ b/jobs/snap/snap-build-prepare.yaml
@@ -61,3 +61,33 @@
61 CI_ID=$BUILD_ID61 CI_ID=$BUILD_ID
62 RESULTS_ID=$BUILD_TAG62 RESULTS_ID=$BUILD_TAG
63 block: true63 block: true
64 - project: '{name}-snap-docs'
65 current-parameters: true
66 block: true
67 predefined-parameters: |
68 ARCHITECTURE=$ARCHITECTURE
69 block: true
70 - project: '{name}-snap-cleanup'
71 current-parameters: true
72 predefined-parameters: |
73 CI_ID=$BUILD_ID
74 RESULTS_ID=$BUILD_TAG
75 block: true
76 publishers:
77 - trigger-parameterized-builds:
78 - project: '{name}-snap-update-mp'
79 condition: "SUCCESS"
80 predefined-parameters: |
81 CI_RESULT=PASSED
82 CI_BUILD=${{BUILD_URL}}
83 CI_BRANCH="${{SOURCE_GIT_REPO_BRANCH}}@${{SOURCE_GIT_REPO}}"
84 CI_MERGE_PROPOSAL=${{MERGE_PROPOSAL}}
85 CI_REVISION=${{REVISION}}
86 - project: '{name}-snap-update-mp'
87 condition: "UNSTABLE_OR_WORSE"
88 predefined-parameters: |
89 CI_RESULT=FAILED
90 CI_BUILD=${{BUILD_URL}}
91 CI_BRANCH="${{SOURCE_GIT_REPO_BRANCH}}@${{SOURCE_GIT_REPO}}"
92 CI_MERGE_PROPOSAL=${{MERGE_PROPOSAL}}
93 CI_REVISION=${{REVISION}}
diff --git a/jobs/snap/snap-build-worker.sh b/jobs/snap/snap-build-worker.sh
index b654b48..e3018c3 100644
--- a/jobs/snap/snap-build-worker.sh
+++ b/jobs/snap/snap-build-worker.sh
@@ -20,10 +20,31 @@ set -ex
2020
21rm -rf $WORKSPACE/src $WORKSPACE/results21rm -rf $WORKSPACE/src $WORKSPACE/results
2222
23git clone git+ssh://$BOT_USERNAME@git.launchpad.net/~$LAUNCHPAD_TEAM/$LAUNCHPAD_PROJECT/+git/$CI_REPO $WORKSPACE/src23CI_BRANCH=$TARGET_GIT_REPO_BRANCH
24
25git clone -b $CI_BRANCH git+ssh://$BOT_USERNAME@git.launchpad.net/~$LAUNCHPAD_TEAM/$LAUNCHPAD_PROJECT/+git/$CI_REPO $WORKSPACE/src
26
27# Try to find the correct branch we need to build from. In the case that
28# $TARGET_GIT_REPO_BRANCH points us to an upstream component branch we
29# will take master as the next suitable candidate.
30cd $WORKSPACE/src
31SNAPCRAFT_YAML_PATH=
32for branch in $CI_BRANCH master ; do
33 git checkout $branch
34 if [ -e "$WORKSPACE/src/snapcraft.yaml" ]; then
35 SNAPCRAFT_YAML_PATH="$WORKSPACE/src/snapcraft.yaml"
36 elif [ -e "$WORKSPACE/src/snap/snapcraft.yaml" ]; then
37 SNAPCRAFT_YAML_PATH="$WORKSPACE/src/snap/snapcraft.yaml"
38 fi
39
40 if [ -n "$SNAPCRAFT_YAML_PATH" ]; then
41 CI_BRANCH=$branch
42 break
43 fi
44done
2445
25if [ ! -e "$WORKSPACE/src/snapcraft.yaml" ] && [ ! -e "$WORKSPACE/src/snap/snapcraft.yaml" ] ; then46if [ -z "$SNAPCRAFT_YAML_PATH" ]; then
26 echo "WARNING: No snapcraft build configuration available"47 echo "WARNING: No snapcraft.yaml found. Not trying to build anything"
27 exit 048 exit 0
28fi49fi
2950
@@ -51,6 +72,11 @@ if [ -e $CI_OVERRIDES_PATH ]; then
51 fi72 fi
52fi73fi
5374
75# We rely on the snapcraft.yaml to have the snap name in the first five lines
76# which is the case for all our snaps. This is a bit lazy but the best way to
77# ensure we don't fetch any other name: fields which might be present in the file.
78SNAP_NAME=$(cat $SNAPCRAFT_YAML_PATH | grep -v ^\# | head -n 5 | grep "^name:" | awk '{print $2}')
79
54if [ "$BUILD_ON_LAUNCHPAD" = False ]; then80if [ "$BUILD_ON_LAUNCHPAD" = False ]; then
55 SNAPBUILD_EXTRA_ARGS=81 SNAPBUILD_EXTRA_ARGS=
56 SNAP_TYPE=$($BUILD_SCRIPTS/tools/shyaml get-value type < $SNAPCRAFT_YAML_PATH || echo app)82 SNAP_TYPE=$($BUILD_SCRIPTS/tools/shyaml get-value type < $SNAPCRAFT_YAML_PATH || echo app)
@@ -79,7 +105,7 @@ else
79105
80 $BUILD_SCRIPTS/tools/trigger-lp-build.py \106 $BUILD_SCRIPTS/tools/trigger-lp-build.py \
81 -s $SNAP_NAME -n \107 -s $SNAP_NAME -n \
82 --git-repo=https://git.launchpad.net/~$LAUNCHPAD_TEAM/$LAUNCHPAD_PROJECT/+git/$CI_REPO \108 --git-repo=git://git.launchpad.net/~$LAUNCHPAD_TEAM/$LAUNCHPAD_PROJECT/+git/$CI_REPO \
83 --git-repo-branch=$CI_BRANCH \109 --git-repo-branch=$CI_BRANCH \
84 --results-dir=$WORKSPACE/results \110 --results-dir=$WORKSPACE/results \
85 $EXTRA_ARGS111 $EXTRA_ARGS
diff --git a/jobs/snap/snap-build.yaml b/jobs/snap/snap-build.yaml
index 3aa338b..6cf7164 100644
--- a/jobs/snap/snap-build.yaml
+++ b/jobs/snap/snap-build.yaml
@@ -60,36 +60,15 @@
60 predefined-parameters: |60 predefined-parameters: |
61 ARCHITECTURE=$ARCHITECTURE61 ARCHITECTURE=$ARCHITECTURE
62 block: true62 block: true
63 - project: '{name}-snap-docs'
64 current-parameters: true
65 block: true
66 - project: '{name}-snap-test'63 - project: '{name}-snap-test'
67 current-parameters: true64 current-parameters: true
68 predefined-parameters: |65 predefined-parameters: |
69 ARCHITECTURE=$ARCHITECTURE66 ARCHITECTURE=$ARCHITECTURE
67 CI_BRANCH=$TARGET_GIT_REPO_BRANCH
70 block: true68 block: true
71 - project: '{name}-snap-cleanup'
72 current-parameters: true
73 publishers:69 publishers:
74 - archive:70 - archive:
75 artifacts: '**/*.snap'71 artifacts: '**/*.snap'
76 latest-only: false72 latest-only: false
77 allow-empty: true73 allow-empty: true
78 fingerprint: false74 fingerprint: false
79 - trigger-parameterized-builds:
80 - project: '{name}-snap-update-mp'
81 condition: "SUCCESS"
82 predefined-parameters: |
83 CI_RESULT=PASSED
84 CI_BUILD=${{BUILD_URL}}
85 CI_BRANCH="${{SOURCE_GIT_REPO_BRANCH}}@${{SOURCE_GIT_REPO}}"
86 CI_MERGE_PROPOSAL=${{MERGE_PROPOSAL}}
87 CI_REVISION=${{REVISION}}
88 - project: '{name}-snap-update-mp'
89 condition: "UNSTABLE_OR_WORSE"
90 predefined-parameters: |
91 CI_RESULT=FAILED
92 CI_BUILD=${{BUILD_URL}}
93 CI_BRANCH="${{SOURCE_GIT_REPO_BRANCH}}@${{SOURCE_GIT_REPO}}"
94 CI_MERGE_PROPOSAL=${{MERGE_PROPOSAL}}
95 CI_REVISION=${{REVISION}}
diff --git a/jobs/snap/snap-test.sh b/jobs/snap/snap-test.sh
index 66876ed..5e68a94 100644
--- a/jobs/snap/snap-test.sh
+++ b/jobs/snap/snap-test.sh
@@ -39,7 +39,7 @@ REMOTE_RESULTS_BASE_DIR=/home/$REMOTE_USER/results
3939
40tmp_srcdir=$(mktemp -d)40tmp_srcdir=$(mktemp -d)
41CI_REPO="ci-build-$CI_ID"41CI_REPO="ci-build-$CI_ID"
42git clone --depth 1 -b $CI_BRANCH https://git.launchpad.net/~$LAUNCHPAD_TEAM/$LAUNCHPAD_PROJECT/+git/$CI_REPO42git clone --depth 1 -b $CI_BRANCH git://git.launchpad.net/~$LAUNCHPAD_TEAM/$LAUNCHPAD_PROJECT/+git/$CI_REPO $tmp_srcdir/src
43cd $tmp_srcdir/src43cd $tmp_srcdir/src
4444
45# Components have the ability to disable CI tests if they can't provide any.45# Components have the ability to disable CI tests if they can't provide any.
@@ -83,7 +83,7 @@ go build github.com/snapcore/spread/cmd/spread
83mkdir /build/bin83mkdir /build/bin
84cp spread /build/bin84cp spread /build/bin
8585
86git clone --depth 1 -b $CI_BRANCH https://git.launchpad.net/~$LAUNCHPAD_TEAM/$LAUNCHPAD_PROJECT/+git/$CI_REPO /build/src86git clone --depth 1 -b $CI_BRANCH git://git.launchpad.net/~$LAUNCHPAD_TEAM/$LAUNCHPAD_PROJECT/+git/$CI_REPO /build/src
87cd /build/src87cd /build/src
8888
89# Copy any stage results from previous generic-build-snap-worker builds89# Copy any stage results from previous generic-build-snap-worker builds

Subscribers

People subscribed via source and target branches

to all changes: