我尝试使用GitLab设置CI,但我收到了这个构建错误:
[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.
我的composer.json看起来像这样:
{
"repositories": [
{
"type": "git",
"url": "git@***.git"
}],
}
这显然与ssh密钥对有关,但我不知道在哪里存储私钥/公钥。
答案 0 :(得分:2)
我刚刚根据https://docs.gitlab.com/ee/ci/ssh_keys/README.html和https://gitlab.com/gitlab-examples/ssh-private-key/blob/master/.gitlab-ci.yml上的示例为此实施了解决方案。
你基本上需要
示例,如果链接被移动:
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