Use snapcraft in CI

In Ubuntu 20.04 snapcraft is now a snap instead of a deb package. Has anyone get snapcraft to work in GitLab CI?

snapd requires systemctl for init, so using snaps in a CI job won’t work with docker executor (default for GitLab.com)

However, snaps can be installed and used in CI jobs if you use a Shell executor for gitlab-runner

https://docs.gitlab.com/runner/install/linux-repository.html#installing-the-runner

Proof of concept CI job using shell runner on 20.04 to install snapd and nmap snap here:

Thank you, but I need it on GitLab.com without installing the runner on my local system. Have you a gitalb-ci.yaml example for GitLab.com?

It’s a little janky, but you can use the unofficial Docker images from cibuilds to build and publish snaps from GitLab CI. This job from the FluffyChat repository is an example (it also shows the somewhat cumbersome workaround you need if your snapcraft.yaml specifies one or more build-snaps).

1 Like