laravel - Gitlab CI/CD 无法下载私有作曲家包
问题描述
我正在尝试使用 Docker 容器内的 gitlab CI/CD 在我的 gitlab 项目中下载一个私有 gitlab 存储库包。
现在我收到以下错误:
- 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'
我尝试了一切,但解决方案..
这篇文章对我没有帮助:GitLab CI:拉私人作曲家包时“权限被拒绝”
信息
- 我正确设置了SSH,因为项目的部署会成功
- 我在我的 repo url 中使用部署令牌,但它没有帮助
- 私钥设置为 gitlab 变量
我的.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
我错过了什么吗?
解决方案
我通过这篇文章解决了这个问题:https ://stackoverflow.com/a/38570269/6385459 这是将公共 SSH 密钥作为部署密钥添加到所有私有依赖项的部分。我有一个错误的 public_key 导致问题..
推荐阅读
- amazon-web-services - 我们可以在同一个 terraform 代码中使用两个云提供商吗
- c++ - 用于智能指针的 std::atomic 的部分模板特化
- kubernetes - Kubernetes pod资源限制/配额占主机资源的百分比(相对)而不是使用绝对值?
- python - 尝试使用调度库来调度函数。收到“无效的时间格式”错误
- selenium-webdriver - 如何在并行运行时截取屏幕截图
- nginx - 使用 VHOST 的单个 VPS 中的多个域
- javascript - Material-ui 有条件禁用收音机
- python-3.x - 将 NaN 替换为组的现有值
- python - 清理字典嵌套字典和字典列表中的字典键
- php - 谷歌视觉 API 中的奇怪错误