我正在设置一个Ubuntu服务器,它有用于CI的Jenkins。
- 当我尝试构建时,我会失败 *
**问题:**如何让npm install
在我的jenkins工作中工作?
构建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
更新:
~$ 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 [email protected]: 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安装之后运行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 [email protected]: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
型
2条答案
按热度按时间z0qdvdin1#
这里有几个问题。
看起来你正在使用
node
0.11。为什么?你需要那个不稳定分支的功能吗?如果没有,我建议使用nodesktop打包的
node
模块,如下所述:https://github.com/nodesource/distributions#usage-instructionscurl -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下载缓存。nr9pn0ug2#
正如它所说:
字符串
npm
在您的路径中不可用,因此请更改作业以指定npm
的完整路径。举例来说:
型
或者
npm
所在的任何地方。