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

In Remmina we have a working solution using a specific image provided by Ubuntu using core20.

See .gitlab-ci.yml · master · Remmina / Remmina · GitLab

Hi @antenore

Is it possible to get a copy of the Dockerfile for registry.gitlab.com/remmina/remmina/snap:22.04?

Thank you

Navigating into the source tree, I think this is the Dockerfile you are looking for ci/dockerfiles/snap-22.04/Dockerfile · master · Remmina / Remmina · GitLab