' node'被詹金斯识别为内部或外部命令错误 [英] 'node' is not recognized as an internal or external command error with jenkins

查看:88
本文介绍了' node'被詹金斯识别为内部或外部命令错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在jenkins v1.592
的帮助下建立持续的代码集成。我有一个Android混合代码,我正在尝试使用jenkins进行构建。
我已经为ANT_HOME,JAVA_HOME,ANDROID_HOME设置了环境变量,然后分别将它们添加到PATH中。我还已将nodejs和npm添加到PATH中。

I am trying to set up continuous code integration with the help of jenkins v1.592 I have an android hybrid code, which I'm, trying to build with jenkins. I have set up environment variables for ANT_HOME, JAVA_HOME, ANDROID_HOME, and added then to the PATH respectively. I also have added nodejs and npm to the PATH.

ant版本1.9.2

ant version 1.9.2

java版本1.8.0_25

java version 1.8.0_25

npm版本1.4.28

npm version 1.4.28

cordova android版本3.5.1

cordova android version 3.5.1

C:\ Users\userName> path

C:\Users\userName>path

给出

C:\Users\userName\AppData\ Roaming\npm; C:\Program Files\nodejs; C:\whateverElse ...

C:\Users\userName\AppData\Roaming\npm;C:\Program Files\nodejs;C:\whateverElse...

jenkins $ WORKSPACE = C:\Program Files(x86 )\Jenkins\jobs\myProject\workspace\

jenkins $WORKSPACE = C:\Program Files (x86)\Jenkins\jobs\myProject\workspace\

现在我将cmd提示符设置为jenkins工作区并执行以下命令

now I set my cmd prompt to jenkins workspace and execute the following commands

  cd myProject
  cordova build android

24秒后我得到BUILD_SUCCESSFUL

I get BUILD_SUCCESSFUL after 24 seconds

类似地,当我转到本地的詹金斯服务器时

Similarly, when I go to my local jenkins server

显示了jenkins仪表板,我在那里设置了myProject,并在项目配置中设置了
,我添加了以下行

The jenkins dashboard is shown and I have set up myProject there and in the project configuration I have added the lines

 "cd myProject
  cordova build android" 

在构建步骤中并保存了配置。
当我尝试构建时,出现以下错误

in the build step and saved the configuration. When I try to build I get the following error

从命令行开始,由匿名
在工作区C:\Program Files(x86 )\Jenkins\jobs\myProject\workspace
更新版本'2014-12-02T15:20:23.437 +0530'
在版本263
以来没有更改先前的版本
[工作区] $ cmd / c调用C:\Windows\TEMP\hudson3297478415472069526.bat

Started from command line by anonymous Building in workspace C:\Program Files (x86)\Jenkins\jobs\myProject\workspace Updating repository at revision '2014-12-02T15:20:23.437 +0530' At revision 263 no change for repository since the previous build [workspace] $ cmd /c call C:\Windows\TEMP\hudson3297478415472069526.bat

C:\Program Files( x86)\Jenkins\jobs\myProject\workspace> cd myProject

C:\Program Files (x86)\Jenkins\jobs\myProject\workspace>cd myProject

C:\Program Files(x86)\Jenkins\jobs \myProject\workspace\myProject> cordova构建android

节点未识别为内部或外部命令,
可操作程序或批处理文件。
构建步骤执行Windows批处理命令将构建标记为失败
归档工件
已完成:失败

任何帮助将不胜感激

在Mac OSX上也存在同样的问题

The same issue exists on mac OSX

最好的问候

推荐答案

这里有几件事可以发挥作用

Several things can be at play here


  1. Did您通过命令行或Windows UI将 node 添加到%PATH%?如果通过UI完成,则可能立即生效。如果通过命令行完成,则直到从外壳程序产生下一个进程时,它才会生效,因此需要重新启动Jenkins服务器。

  1. Did you add node to %PATH% through command line, or through the Windows UI? If done through UI, it can take affect immediatelly. If done through command line, it doesn't take affect until the next process spawns from shell, therefore Jenkins server restart is required.

Jenkins以本地Windows上默认为系统。您将 C:\Users\userName 列为路径的一部分,即用户特定的路径。您是为所有用户设置%PATH%还是仅为用户 userName 设置了?如果未为所有用户(或与Jenkins一起运行的特定用户)设置,则Jenkins将看不到它。您可以更改服务运行的用户身份。

Jenkins runs as "Local System" by default on Windows. You are listing C:\Users\userName as part of your paths, i.e. a user specific path. Did you set the %PATH% for all users, or just for your user userName? If it's not set for all users (or a specific user that Jenkins runs with), then Jenkins won't see it. You can change what user the service runs as.

2a。如果Jenkins以本地系统用户身份运行,该帐户是否可以访问 C:\Users\userName

2a. If Jenkins is running as "Local System" user, does that account have access to C:\Users\userName?


  1. 最后,如果您从命令行设置了%PATH%,您是否将其设置为永久使用 setx 命令输入?

  1. And lastly, if you set the %PATH% from command line, did you set it as a permanent entry using setx command?

无论哪种情况,都可以从您的作业配置中添加一个构建步骤执行Windows批处理命令,然后仅键入 set (以显示所有环境变量)或 @echo%PATH%(仅查看%PATH%)并验证环境设置是否正确

In either case, from your job configuration, add a build step "Execute Windows Batch Command" and type just set (to display all environment variables) or @echo %PATH% (to see just the %PATH%) and verify that the environment is set correctly

这篇关于' node'被詹金斯识别为内部或外部命令错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆