Error failed to fetch an image or build from source: error connecting to docker: You must be authenticated to view this.

So I am trying to deploy using gitlab ci/cd but I keep not being authenticated to heartbeat?
.gitlab-ci.yml deployment stage:

fly-deploy:
  stage: deploy
  before_script:
    - apt-get update -qq && apt-get install -y curl
    - curl -L https://fly.io/install.sh | sh
    - export FLYCTL_INSTALL="/root/.fly"
    - export PATH="$FLYCTL_INSTALL/bin:$PATH"
  variables:
    FLY_API_TOKEN: $FLY_API_TOKEN
  script:
    - flyctl deploy --remote-only

Log:

Any idea why this happens?

Is that FLY_API_TOKEN set in your GitLab project settings? A useful experiment here might be to add before the deploy script line something like:

- flyctl status

to see that its able to pick up the auth for the API at all. You could also set LOG_LEVEL=debug to get a little more logs that might give us some better indication what’s going on.

In case its useful I had to get a refresher on the GitLab variable setup: GitLab CI/CD variables | GitLab

3 Likes

You sir are very correct! It was the branch privilege that was the problem when setting the variable to protected. In any case if someone else is stuck follow this guide to set a protected branch:

1 Like