I'm trying to setup CI with GitLab but I'm getting this build error:
[RuntimeException]
Failed to execute git clone --no-checkout 'git@***.git' '/builds/***' && cd '/builds/***' && git remote add composer 'git@***.git' && git fetch composer
Cloning into '/builds/***'...
Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
My composer.json looks like this:
{
"repositories": [
{
"type": "git",
"url": "git@***.git"
}],
}
It obviously has something to do with the ssh key pair, but I don't know where to store the private/public keys.
I just implemented a solution for this, based on https://docs.gitlab.com/ee/ci/ssh_keys/README.html and the example on https://gitlab.com/gitlab-examples/ssh-private-key/blob/master/.gitlab-ci.yml.
You basically need to
Example, in case the link gets moved:
before_script:
# install ssh-agent
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
# run ssh-agent
- eval $(ssh-agent -s)
# add ssh key stored in SSH_PRIVATE_KEY variable to the agent store
- ssh-add <(echo "$SSH_PRIVATE_KEY")
# Set up project.
- composer install
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With