GitLab + GitLab CI + 通过 NPM 实现依赖 SSH 项目

3

目前我们使用GitLab来管理代码库和GitLab CI作为持续集成的工具。

我有一个项目,其中包含另一个GitLab项目作为依赖项(通过NPM)。该项目是内部项目,package.json中的URL以git+ssh://git@开头,这也是我们在本地机器上使用的方式。我们已经设置了SSH密钥。

然而,GitLab CI似乎无法使用相同的机制来安装这个依赖项目(通过npm install)。

我收到的错误信息是:

npm install
npm ERR! git clone git@my.domain.com:developers/my-repo.git Cloning into bare repository '/home/gitlab_ci_runner/.npm/_git-remotes/git-my-domain-com-developers-my-git-26043eba'...
npm ERR! git clone git@my.domain.com:developers/my-repo.git
npm ERR! git clone git@my.domain.com:developers/my-repo.git Host key verification failed.
npm ERR! git clone git@my.domain.com:developers/my-repo.git fatal: The remote end hung up unexpectedly
npm ERR! Error: Command failed: Host key verification failed.
npm ERR! fatal: The remote end hung up unexpectedly
npm ERR! 
npm ERR!     at ChildProcess.exithandler (child_process.js:658:15)
npm ERR!     at ChildProcess.emit (events.js:98:17)
npm ERR!     at maybeClose (child_process.js:766:16)
npm ERR!     at Socket.<anonymous> (child_process.js:979:11)
npm ERR!     at Socket.emit (events.js:95:17)
npm ERR!     at Pipe.close (net.js:466:12)
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR!     <http://github.com/npm/npm/issues>

npm ERR! System Linux 3.2.0-68-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! cwd /home/gitlab_ci_runner/gitlab-ci-runner/tmp/builds/project-9
npm ERR! node -v v0.10.37
npm ERR! npm -v 1.4.28
npm ERR! code 128
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/gitlab_ci_runner/gitlab-ci-runner/tmp/builds/project-9/npm-debug.log
npm ERR! not ok code 0

我们缺少什么?我需要一个不需要我更改package.json中的URL的解决方案。

对于任何正在寻找答案的人 -> 这里 - A1rPun
1个回答

0

您需要在CI服务器上的~/.ssh/known_hosts中放置正确的主机(my.domain.com)密钥。

通常只需从~/.ssh/known_hosts中删除带有密钥的行,然后至少使用ssh一次以缓存密钥即可。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接