[英]Jenkins with node and pm2
I have pm2 installed which also manages the node versions. 我安装了pm2,它也管理节点版本。 When I run "node -v" in terminal it works fine.
当我在终端中运行“ node -v”时,它可以正常工作。 But when I run "node -v" in Jenkins shell script then it says node not found.
但是,当我在Jenkins shell脚本中运行“ node -v”时,它说未找到节点。
If your build machine is a windows machine, you'll need to restart the jenkins agent every time you change your PATH, so that the slave agent/service picks up the change. 如果您的构建计算机是Windows计算机,则每次更改PATH时都需要重新启动jenkins代理,以便从代理/服务获取更改。 I am not sure if this would be a problem for build nodes in other OS, but and out of date PATH would explain your symptoms.
我不确定这是否会对其他OS中的构建节点造成问题,但是过时的PATH可以解释您的症状。
To confirm whether an out of date PATH
is the issue, I would check the contents of the path from terminal, by running echo $PATH
, and also check where node is installed by running which node
. 为了确认是否存在过时的
PATH
问题,我将通过运行echo $PATH
来检查来自终端的路径的内容,并通过运行which node
检查节点的安装位置。 The node install location will be in the PATH since terminal can find node
. 由于终端可以找到
node
因此节点的安装位置将位于PATH中。
Then I would look at PATH
as seen from Jenkins, either by running echo $PATH
on a shell step of a jenkins job or by clicking on the build node in jenkins -> "System Information"-> ctrl+F "path". 然后,我可以从Jenkins看一下
PATH
,方法是在jenkins作业的shell步骤上运行echo $PATH
,或者单击jenkins->“系统信息”-> ctrl + F“路径”中的构建节点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.