Building and pushing snap packages from GitLab


Maybe this information could be useful on documentation. Since there is no support for GitLab on, you can use the following:

  1. Login into snapcraft, create a credential file, convert in base64 and copy to clipboard

    snapcraft login
    snapcraft export-login snapcraft.login
    base64 snapcraft.login | xsel --clipboard
  2. Set GitLab-CI variable with your credentials

  • Go to your project Settings - CI / CD
  • on Environment Variables, add SNAPCRAFT_LOGIN_FILE with your credentials from the clipboard
  • click on Save variables
  1. create or edit a file in your project root folder called .gitlab-ci.yml with the following content (you can edit as you need)

      image: ubuntu:18.04
      type: deploy
        - apt-get update -qy
        - apt-get install -y snapcraft 
        - snapcraft
        - echo $SNAPCRAFT_LOGIN_FILE | base64 --decode --ignore-garbage > snapcraft.login
        - snapcraft login --with snapcraft.login
        - snapcraft push *.snap --release edge
        - master

Hello Jonata,

Just adding a reference here to these other topics:
on how to do the build stage properly in 20.04 now that snapcraft is distributed as a snap instead of a deb.

1 Like