I'm trying to download a private gitlab repository package inside my gitlab project, using the gitlab CI/CD inside a Docker container.
Now I got the following error:
- Installing {package} (dev-master 30bb2f3): Downloading Failed to download {package} from dist: Could not authenticate against gitlab.com
80 Now trying to download from source
81 - Installing {package} (dev-master 30bb2f3): Cloning 30bb2f3bb7
82
83 [RuntimeException]
84 Failed to execute git clone --no-checkout 'git@gitlab.com:{user}/{project}/{repo}.git'
I tried everything, but the solution..
This post didn't help me: GitLab CI: "Permission denied" when pulling private composer package
Info
- I setup SSH correctly, because the deployment of the project will succeed
- I use deploy tokens in my repo url, but it didn't helped
- The private key is set as gitlab variable
My .gitlab-ci.yml
.init_ssh: &init_ssh |
which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )
eval $(ssh-agent -s)
echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
mkdir -p ~/.ssh
chmod 700 ~/.ssh
ssh-keyscan gitlab.com >> ~/.ssh/known_hosts
chmod 644 ~/.ssh/known_hosts
echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
Composer:
stage: Build
script:
- *init_ssh
- composer install --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts
Am I missing something?