我正在设置一个拥有jenkins for CI的ubuntu服务器。
当我尝试运行构建时,我遇到了失败
问题:
如何从我的詹金斯工作中使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
詹金建立
更新
~$ 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'
...
所以我已经找到了文件夹:
+ pwd
/var/lib/jenkins/workspace/morningharwood
sudo chown ubuntu /var/lib/jenkins/workspace/morningharwood/ -Rv
...
之后运行npm install npm install
成功了!
新问题: 当我尝试通过jenkins从github克隆存储库时,我的构建现在失败了。
控制台日志
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 :(得分:10)
这里有几个问题。
看起来您正在使用node
0.11。为什么?你需要那个不稳定分支的功能吗?
如果没有,我建议使用nodesource打包的node
模块,如下所述:https://github.com/nodesource/distributions#usage-instructions
curl -sL https://deb.nodesource.com/setup | sudo bash -
sudo apt-get install -y nodejs
这会让您在全局路径中安装node
和npm
,ubuntu
用户和jenkins
用户都可以看到。
最后,/home/ubuntu/.npm/npm
不是可执行文件,而是npm
包的缓存版本; /home/ubuntu/.npm
是每用户npm下载缓存。
答案 1 :(得分:2)
正如它所说的
/tmp/hudson8925730298288495807.sh: 5: /tmp/hudson8925730298288495807.sh: npm: not found
npm
在您的路径中不可用,因此请更改您的工作以指定npm
的完整路径
例如
/usr/local/bin/npm install
或npm
位于<{p}}