我有一个运行良好的bitbucket管道,但现在我需要从私有存储库中提取,其中包含我的composer.json中需要的包 .
当我在管道中安装作曲家时,它会因此错误而停止
Failed to execute git clone --no-checkout 'git@bitbucket.org:company/package.git' [...]
Cloning into '/opt/atlassian/pipelines/agent/build/vendor/company/package'...
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
管道没有定义任何SSH密钥,因此不允许拉,但是我怎么能定义一个,因为它是短暂的?
或者我可能应该定义要求吗?
1 回答
将部署密钥(公共SSH密钥)添加到专用存储库
将该密钥的相应私钥(Base64编码)添加为具有管道的仓库中的环境变量 . 理想情况下,这应该被标记为受保护,这将隐藏它 .
在管道中使用环境变量(Base64-decoding) . 通常,这意味着将其写入用户的
.ssh
目录 .这应该足以让它运行 .
此外,我刚刚看到现在(可能这是新的,但我不确定)新页面“设置”>“管道”>“SSH密钥”,用于管理管道SSH密钥 . 这样,您甚至不需要将私钥添加到正在使用的docker镜像中 . 但到目前为止我还没有使用过,所以我不能说出来 .