GitLab + GitLab CI +通过NPM从属SSH项目

目前我们使用GitLab来pipe理我们的回购和GitLab CI作为我们的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 

我们缺less什么? 我需要一个不需要我更改package.json的URL的解决scheme。

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

通常只需要用~/.ssh/known_hosts的键删除这行,然后至less一次ssh进入caching键。