jenkins Jenkin的构建在npm安装时失败

j13ufse2  于 9个月前  发布在  Jenkins
关注(0)|答案(2)|浏览(211)

我正在设置一个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

z0qdvdin

z0qdvdin1#

这里有几个问题。
看起来你正在使用node 0.11。为什么?你需要那个不稳定分支的功能吗?
如果没有,我建议使用nodesktop打包的node模块,如下所述:https://github.com/nodesource/distributions#usage-instructions
curl -sL https://deb.nodesource.com/setup | sudo bash - sudo apt-get install -y nodejs
这将使您在全局路径中很好地安装nodenpm,对ubuntu用户和jenkins用户都可见。
最后,/home/ubuntu/.npm/npm不是可执行文件,而是npm包的缓存版本; /home/ubuntu/.npm是每个用户的npm下载缓存。

nr9pn0ug

nr9pn0ug2#

正如它所说:

/tmp/hudson8925730298288495807.sh: 5: /tmp/hudson8925730298288495807.sh: npm: not found

字符串
npm在您的路径中不可用,因此请更改作业以指定npm的完整路径。
举例来说:

/usr/local/bin/npm install


或者npm所在的任何地方。

相关问题