Jenkins上的npm / nodejs

时间:2017-03-16 14:41:15

标签: node.js jenkins npm ubuntu-14.04

我试图让npm / nodejs在Jenkins(v2.32.3)上运行,但在将Nodejs插件从0.2.2升级到1.1.2后出现问题。

我手动下载了Nodej并在/etc/nodejs/node-v6.9.4-linux-x64中提取了它,我已在全局工具配置中对其进行了配置。

我有一个像这样配置的简单作业(执行shell):

echo $PATH
whoami
npm --version
node --version

结果是:

[EnvInject] - Loading node environment variables.
Building in workspace /var/lib/jenkins/jobs/test- nodejs_test/workspace
[workspace] $ /bin/sh -xe /tmp/hudson1755936462393481437.sh
+ echo /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
+ whoami
jenkins
+ npm --version
/tmp/hudson1755936462393481437.sh: 4: /tmp/hudson1755936462393481437.sh: npm: not found
Build step 'Execute shell' marked build as failure
Started calculate disk usage of build
Finished Calculation of disk usage of build in 0 seconds
Started calculate disk usage of workspace
Finished Calculation of disk usage of workspace in 0 seconds
Finished: FAILURE

我不知道为什么会失败,我相信这是因为没有设置PATH。但是,如果我登录Jenkins服务器并在/etc/environment中指定了PATH,它在shell中工作,但在Jenkins中不能工作:

jenkins@JENIS-SERVER:/home/user$ npm --version
3.10.10

1 个答案:

答案 0 :(得分:1)

Jenkins在连接代理时不使用登录shell。

您可以通过代理的配置页面添加PATH,方法是选中“环境变量”并添加名称为PATH+NPM的{​​{1}}之后的名称任何事情),以及价值+