如何从bitbucket管道中的私人仓库中提取?

时间:2017-04-17 14:21:06

标签: git bitbucket bitbucket-pipelines

我有一个运行良好的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 个答案:

答案 0 :(得分:2)

  • 将部署密钥(公共SSH密钥)添加到专用存储库
  • 将该密钥的相应私钥(Base64编码)添加为具有管道的仓库中的环境变量。理想情况下,这应该被标记为受保护,这将隐藏它。
  • 在管道中使用环境变量(Base64解码)。通常,这意味着将其写入用户的.ssh目录。

这应该足以让它运行。

此外,我刚刚看到现在有(可能这是新的,但我不确定)新页面“设置”> “管道”>用于管理管道SSH密钥的“SSH密钥”。这样,您甚至不需要将私钥添加到正在使用的docker镜像中。但到目前为止我还没有使用过,所以我不能对此发表任何意见。

相关问题