Cloning a private repository fails in GitLab CI

I'm using GitLab CI and I have two dependencies to clone from the same GitLab Server.

One of my dependencies is in Composer and the other one in NPM. Both of the commands (composer install and npm ci) fail during the git clone.

Here is the output npm produces: (with the repository names redacted)

npm ERR! /usr/bin/git ls-remote -h -t :in-house/repository.git
npm ERR!
npm ERR! > GitLab: The project you were looking for could not be found.
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
npm ERR!
npm ERR! exited with error code: 128

And same goes for composer:

 [RuntimeException] Failed to execute git clone --no-checkout ':forks/repository.git' '/builds/repo/vendor/repository' && cd '/builds/repo/repository' && git remote add composer ':forks/repository.git' && git fetch composer 

I have a deploy key defined in my admin area and the private key gets added correctly to the runner, following the gitlab tutorial from their website. As shown by the line Identity added: (stdin) (ci@gitlab) on every pipeline.

When adding the same private key to a throwaway docker container on my local machine and cloning the repositories from that container everything works as expected. Even when using the same ssh package and dependency managers.

The docker container we are using for the CI is a private one too, hosted in GitLab's container registry, based off Alpine Linux.

1 Answer

I figured out my mistake. I added the deploy token to the admin area. not to the repository. So it did not have access to the repository.

During the verification in the throwaway docker container, I must have accidentally pasted my own key instead of the one in the CI.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like