简体   繁体   English

詹金斯与节点和PM2

[英]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“路径”中的构建节点。

Hey i had the same issue you need to go to jenkins and add the nodejs plugin and add an installation of it 嘿,我遇到了同样的问题,您需要去jenkins并添加nodejs插件并添加它的安装

you go to Settings => Global Tool Configuration add a nodejs installation 你去设置=>全局工具配置添加一个nodejs安装

设置部分

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM