Jenkin的构建在npm install上失败了 [英] Jenkin's build failing on npm install

查看:241
本文介绍了Jenkin的构建在npm install上失败了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设置一个拥有jenkins for CI的ubuntu服务器。

I'm setting up an ubuntu server that has jenkins for CI.

当我尝试运行构建时,我失败了

问题:
如何从我的jenkins中 c> npm install 工作工作?

构建1:

[morningharwood] $ /bin/sh -xe /tmp/hudson8925730298288495807.sh
+ pwd
/var/lib/jenkins/workspace/morningharwood
+ ls
bower.json
client
e2e
Gruntfile.js
karma.conf.js
package.json
protractor.conf.js
server
+ npm install
/tmp/hudson8925730298288495807.sh: 5: /tmp/hudson8925730298288495807.sh: npm: not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE

Jenkin build

Jenkin build

更新:

~$ pwd
/home/ubuntu

ls -a


.   .bash_history  .bashrc  .config    .gem    .gnupg  .node-gyp  .nvm      .rbenv  .ssh  .viminfo
..  .bash_logout   .cache   .dotfiles  .gemrc  .local  .npm       .profile  .rvm    .vim

现在我看到 .npm

+ /home/ubuntu/.npm/npm install
/tmp/hudson1456103398115324880.sh: 5: /tmp/hudson1456103398115324880.sh: /home/ubuntu/.npm/npm: not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE

配置脚本:

从ssh终端运行时会发生什么?

npm WARN engine karma@0.12.28: wanted: {"node":"~0.8 || ~0.10"} (current: {"node":"0.11.14","npm":"2.0.0"})
npm ERR! Linux 3.13.0-36-generic
npm ERR! argv "/home/ubuntu/.nvm/v0.11.14/bin/node" "/home/ubuntu/.nvm/v0.11.14/bin/npm" "install"
npm ERR! node v0.11.14
npm ERR! npm  v2.0.0
npm ERR! path /var/lib/jenkins/workspace/morningharwood/node_modules
npm ERR! code EACCES
npm ERR! errno -13

npm ERR! Error: EACCES, mkdir '/var/lib/jenkins/workspace/morningharwood/node_modules'
...

所以我已经知道该文件夹:

So I've CHOWN the folder:

   + pwd
    /var/lib/jenkins/workspace/morningharwood
   sudo chown ubuntu /var/lib/jenkins/workspace/morningharwood/ -Rv
   ...


npm安装之后安装npm安装

Ran npm install after that npm install

成功了!

新问题:
尝试通过jenkins从github克隆存储库时,我的构建现在失败了。

NEW PROBLEM: My build now fails when trying to clone the repository from github via jenkins.

控制台日志

    Started by user matthew harwood
Building in workspace /var/lib/jenkins/workspace/morningharwood
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url git@github.com:matthewharwood/morningharwood.git # timeout=10
ERROR: Error fetching remote repo 'origin'
ERROR: Error fetching remote repo 'origin'
Finished: FAILURE

显示所有者:

ls -la
drwxr-xr-x  3 jenkins jenkins 4096 Dec 26 20:31 .
drwxr-xr-x 13 jenkins jenkins 4096 Dec 26 08:23 ..
drwxr-xr-x  7 ubuntu  jenkins 4096 Dec 26 20:59 morningharwood


推荐答案

这里有几个问题。

它看起来你正在使用节点 0.11。为什么?你需要来自那个不稳定分支的功能吗?

It looks like you are using node 0.11. Why? Do you need a feature from that unstable branch?

如果没有,我建议使用nodesource打包的节点模块,如下所述: https://github.com/nodesource/distributions#usage-instructions

If not, I would recommend using the nodesource packaged node modules, as described here: https://github.com/nodesource/distributions#usage-instructions

curl -sL https://deb.nodesource.com/setup | sudo bash -
sudo apt-get install -y nodejs

这将为您提供良好的安装<全局路径中的code> node 和 npm ,对于 ubuntu 用户和 jenkins 用户。

This will get you a good installation of node and npm in the global path, visible to both your ubuntu user and the jenkins user.

最后, /home/ubuntu/.npm / npm 不是可执行文件,而是 npm 包的缓存版本; /home/ubuntu/.npm 是每用户npm下载缓存。

Finally, /home/ubuntu/.npm/npm is not an executable, but is the cached version of the npm package; /home/ubuntu/.npm is the per-user npm download cache.

这篇关于Jenkin的构建在npm install上失败了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆