Grunt与Jenkins在windows问题上的集成

Grunt与Jenkins在windows问题上的集成,jenkins,gruntjs,Jenkins,Gruntjs,我在Tomcat7-Windows7上运行Jenkins。我在jenkins配置中提供了节点bin路径。然后运行shell脚本,如下所示: echo $PATH node --version npm install -g grunt-cli npm install grunt cssmin 正如在另一篇文章中所建议的,我已经多次重新启动我的jenkins,并尝试处理该文章中所写的所有答案,但仍然显示错误,grunt:command not found jenkins控制台输出的错误堆栈跟踪:

我在Tomcat7-Windows7上运行Jenkins。我在jenkins配置中提供了节点bin路径。然后运行shell脚本,如下所示:

echo $PATH
node --version
npm install -g grunt-cli
npm install
grunt cssmin
正如在另一篇文章中所建议的,我已经多次重新启动我的jenkins,并尝试处理该文章中所写的所有答案,但仍然显示错误,grunt:command not found

jenkins控制台输出的错误堆栈跟踪:

/c/apache-maven-3.2.5/bin:/c/Program Files/Java/jdk1.7.0_79/bin:/c/Program Files/nodejs/bin:/c/Program Files/Java/jdk1.7.0_79/bin:/c/Program Files/nodejs/:

+ node --version
v0.10.30
+ npm install -g grunt-cli
C:\Windows\system32\config\systemprofile\AppData\Roaming\npm\grunt -> C:\Windows\system32\config\systemprofile\AppData\Roaming\npm\node_modules\grunt-cli\bin\grunt
grunt-cli@0.1.13 C:\Windows\system32\config\systemprofile\AppData\Roaming\npm\node_modules\grunt-cli
├── resolve@0.3.1
├── nopt@1.0.10 (abbrev@1.0.7)
└── findup-sync@0.1.3 (lodash@2.4.2, glob@3.2.11)
+ npm install
npm WARN package.json Trademust@1.0.0 No repository field.
+ grunt cssmin
C:\Program Files\Apache Software Foundation\Tomcat 7.0\temp\hudson2968878175697925824.sh: line 6: grunt: command not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE
我也遵循了这个网站上提到的步骤

当我第一次执行jenkins构建时,package.json和Gruntfile.js就在根目录中,grunt安装了我的Gruntfile.js中的所有模块,然后在所有其他构建的its中显示上述输出


任何人都可以检查这里出了什么问题。

从错误消息中,sheel似乎无法找到grunt。请检查$PATH变量中是否存在该变量。此shell脚本正在哪个节点上运行?您可以检查特定节点的$PATH。您还可以在shell脚本期间将grunt安装路径添加到$path变量

grunt_path="grunt_installtion_path"
export PATH=${PATH}:${grunt_path}

在搜索了很多之后,我找到了grunt的安装位置。就jenkins build而言,它安装在
驱动器:/.jenkins……/workspace/node_modules/.bin

使用shell脚本
导出路径=$path:drive:/.jenkins……/workspace/node\u modules/.bin在jenkins中提供此路径后,grunt开始执行


在这个过程中,我还学到了检查可执行文件在系统路径上的位置,或者jenkins所指的路径使用的是没有qoutes的
哪个“可执行文件名称”
。您可以在windows和linux上使用此命令。例如:
哪个grunt
将显示grunt可执行文件所在的路径。

路径变量中不存在grunt,因为grunt不是全局安装的,而是每个项目的本地安装的。它即使在我的本地系统环境变量上也不可用,但我仍然可以在我的特定项目中使用grunt执行所有任务。我已经编辑了环境路径,并将其包含在我的问题中。自从我在项目文件夹中运行npm安装以来,在哪里可以找到grunt_路径。