canonical-hw-cert team mailing list archive
-
canonical-hw-cert team
-
Mailing list archive
-
Message #30406
[Merge] ~pgentili/hwcert-jenkins-jobs:zapper-snap into hwcert-jenkins-jobs:master
Paolo Gentili has proposed merging ~pgentili/hwcert-jenkins-jobs:zapper-snap into hwcert-jenkins-jobs:master.
Commit message:
Add: build the Zapper snap using cert Jenkins arm builders
Requested reviews:
Sylvain Pineau (sylvain-pineau)
For more details, see:
https://code.launchpad.net/~pgentili/hwcert-jenkins-jobs/+git/hwcert-jenkins-jobs/+merge/431902
Added a project which inherits from 3 templates: arm64, armhf and trigger-arm (local version).
JIRA: https://warthogs.atlassian.net/browse/ZAP-235
Had to modify several things in the template/scripts:
1) Added "source-subdir" variable: needed because "snap/" is not placed in root directory. Zapper Control code is in a subdirectory of the repo, hence the "snap/" placement.
2) Added "ssh-credential-id" variable: needed because of GitHub's policies around deploy keys. Each project living in GitHub will require a different key pair. Only added in "local" templates.
3) Changed "snapcraft" call: actual version is not working with Snapcraft 7.x for a couple of reasons. (1) "--destructive-mode" does not work when called with `sudo -u ubuntu` (apt update fails). (2) regular mode fails because it's using lxd inside lxd.
--
Your team hwcert-jenkins is subscribed to branch hwcert-jenkins-jobs:master.
diff --git a/jobs/infrastructure/build-checkbox/snap-build-checkbox.yaml b/jobs/infrastructure/build-checkbox/snap-build-checkbox.yaml
index a403788..e8472dc 100644
--- a/jobs/infrastructure/build-checkbox/snap-build-checkbox.yaml
+++ b/jobs/infrastructure/build-checkbox/snap-build-checkbox.yaml
@@ -91,8 +91,10 @@
snap: snapcraft
channel: stable
source-branch: master
+ source-subdir: ''
lxd_template: ubuntu:x
push_snap: true
+ ssh-credential-id: 'ssh-ce-certification-qa'
properties:
- build-discarder:
num-to-keep: 14
@@ -103,10 +105,10 @@
fail: true
- ssh-agent-credentials:
users:
- - 'ssh-ce-certification-qa'
+ - '{ssh-credential-id}'
- credentials-binding:
- ssh-user-private-key:
- credential-id: ssh-ce-certification-qa
+ credential-id: '{ssh-credential-id}'
key-file-variable: GIT_SSH_KEY
username-variable: GITUSER
- text:
@@ -118,7 +120,7 @@
!include-raw: jobs/snap-build-test/snap-build-test.sh
publishers:
- archive:
- artifacts: 'project/*.snap'
+ artifacts: 'project/{source-subdir}/*.snap'
allow-empty: true
- email:
recipients: ce-certification-qa@xxxxxxxxxxxxxxxxxxx
@@ -131,8 +133,10 @@
snap: snapcraft
channel: stable
source-branch: master
+ source-subdir: ''
lxd_template: ubuntu:x
push_snap: true
+ ssh-credential-id: 'ssh-ce-certification-qa'
properties:
- build-discarder:
num-to-keep: 14
@@ -143,10 +147,10 @@
fail: true
- ssh-agent-credentials:
users:
- - 'ssh-ce-certification-qa'
+ - '{ssh-credential-id}'
- credentials-binding:
- ssh-user-private-key:
- credential-id: ssh-ce-certification-qa
+ credential-id: '{ssh-credential-id}'
key-file-variable: GIT_SSH_KEY
username-variable: GITUSER
- text:
@@ -158,7 +162,7 @@
!include-raw: jobs/snap-build-test/snap-build-test.sh
publishers:
- archive:
- artifacts: 'project/*.snap'
+ artifacts: 'project/{source-subdir}/*.snap'
allow-empty: true
- email:
recipients: ce-certification-qa@xxxxxxxxxxxxxxxxxxx
@@ -171,8 +175,10 @@
snap: snapcraft
channel: stable
source-branch: master
+ source-subdir: ''
lxd_template: ubuntu:x
push_snap: true
+ ssh-credential-id: 'ssh-ce-certification-qa'
properties:
- build-discarder:
num-to-keep: 14
@@ -183,10 +189,10 @@
fail: true
- ssh-agent-credentials:
users:
- - 'ssh-ce-certification-qa'
+ - '{ssh-credential-id}'
- credentials-binding:
- ssh-user-private-key:
- credential-id: ssh-ce-certification-qa
+ credential-id: '{ssh-credential-id}'
key-file-variable: GIT_SSH_KEY
username-variable: GITUSER
- text:
@@ -198,7 +204,7 @@
!include-raw: jobs/snap-build-test/snap-build-test.sh
publishers:
- archive:
- artifacts: 'project/*.snap'
+ artifacts: 'project/{source-subdir}/*.snap'
allow-empty: true
- email:
recipients: ce-certification-qa@xxxxxxxxxxxxxxxxxxx
@@ -279,16 +285,17 @@
name: 'snap-build-{name}-local-trigger'
node: snapbuild
source-branch: master
+ ssh-credential-id: 'ssh-ce-certification-qa'
properties:
- build-discarder:
num-to-keep: 10
wrappers:
- ssh-agent-credentials:
users:
- - 'ssh-ce-certification-qa'
+ - '{ssh-credential-id}'
- credentials-binding:
- ssh-user-private-key:
- credential-id: ssh-ce-certification-qa
+ credential-id: '{ssh-credential-id}'
key-file-variable: GIT_SSH_KEY
username-variable: GITUSER
triggers:
@@ -315,16 +322,17 @@
name: 'snap-build-{name}-local-trigger-arm'
node: snapbuild
source-branch: master
+ ssh-credential-id: 'ssh-ce-certification-qa'
properties:
- build-discarder:
num-to-keep: 10
wrappers:
- ssh-agent-credentials:
users:
- - 'ssh-ce-certification-qa'
+ - '{ssh-credential-id}'
- credentials-binding:
- ssh-user-private-key:
- credential-id: ssh-ce-certification-qa
+ credential-id: '{ssh-credential-id}'
key-file-variable: GIT_SSH_KEY
username-variable: GITUSER
triggers:
diff --git a/jobs/infrastructure/build-zapper/snap-build-zapper-control.yaml b/jobs/infrastructure/build-zapper/snap-build-zapper-control.yaml
new file mode 100644
index 0000000..0a90c8f
--- /dev/null
+++ b/jobs/infrastructure/build-zapper/snap-build-zapper-control.yaml
@@ -0,0 +1,16 @@
+- project:
+ name: 'zapper-control'
+ description: |
+ This job will build and publish Zapper Control
+ source-url: git@xxxxxxxxxx:canonical/zapper.git
+ source-branch: main
+ source-subdir: 'zapper-control'
+ check-branches: ''
+ release-targets: 'latest/edge'
+ lxd_template: ubuntu:focal
+ channel: '7.x/stable'
+ ssh-credential-id: 'ssh-github-zapper'
+ jobs:
+ - 'snap-build-{name}-local-armhf'
+ - 'snap-build-{name}-local-arm64'
+ - 'snap-build-{name}-local-trigger-arm'
diff --git a/jobs/snap-build-test/snap-build-test.sh b/jobs/snap-build-test/snap-build-test.sh
index fafc108..262973b 100644
--- a/jobs/snap-build-test/snap-build-test.sh
+++ b/jobs/snap-build-test/snap-build-test.sh
@@ -27,7 +27,7 @@ EOF
# Check out the project we want to build
-rm -rf project
+sudo rm -rf project
git clone --depth 1 -b {source-branch} {source-url} project
# Build the lxc container
@@ -40,7 +40,7 @@ lxc delete $JOB_NAME
lxc init {lxd_template} $JOB_NAME
lxc config set "$JOB_NAME" raw.idmap "both $UID 1000"
lxc config device add "$JOB_NAME" sshconf disk source=$HOME/.hwcert_creds path=/home/ubuntu/.ssh
-lxc config device add "$JOB_NAME" project disk source=$PWD/project path=/home/ubuntu/project
+lxc config device add "$JOB_NAME" project disk source=$PWD/project/{source-subdir} path=/home/ubuntu/project
lxc start "$JOB_NAME"
sleep 60
lxc exec "$JOB_NAME" -- chown ubuntu.ubuntu /home/ubuntu
@@ -52,13 +52,13 @@ lxc exec "$JOB_NAME" -- bash -c "DEBIAN_FRONTEND=noninteractive apt install squa
lxc exec "$JOB_NAME" -- bash -c "DEBIAN_FRONTEND=noninteractive apt install snapd -y"
# Make snapcraft available
lxc exec "$JOB_NAME" -- snap install snapcraft --classic --channel={channel}
-lxc exec "$JOB_NAME" -- sudo -iu ubuntu bash -c "cd project && (snapcraft --destructive-mode || snapcraft) | tee buildlog.txt"
+lxc exec "$JOB_NAME" -- sudo bash -c "cd /home/ubuntu/project && snapcraft --destructive-mode | tee buildlog.txt"
EXITCODE=${{PIPESTATUS[0]}}
lxc stop -f $JOB_NAME
lxc delete $JOB_NAME
if [ -n "{push_snap}" ]; then
- snapcraft upload project/*.snap --release {release-targets}
+ snapcraft upload project/{source-subdir}/*.snap --release {release-targets}
EXITCODE=$?
fi
diff --git a/jobs/snap-build-test/snap-build-test.yaml b/jobs/snap-build-test/snap-build-test.yaml
index 84ad727..37d169d 100644
--- a/jobs/snap-build-test/snap-build-test.yaml
+++ b/jobs/snap-build-test/snap-build-test.yaml
@@ -7,6 +7,7 @@
lxd_template: ubuntu:bionic
push_snap: ''
release-targets: ''
+ source-subdir: ''
wrappers:
- timestamps
- timeout:
@@ -25,7 +26,7 @@
description: "\\1 - r\\2"
description-for-failed: "\\1 - r\\2"
- archive:
- artifacts: 'project/*.snap'
+ artifacts: 'project/{source-subdir}/*.snap'
allow-empty: true
- email:
recipients: ce-certification-qa@xxxxxxxxxxxxxxxxxxx
Follow ups