我在Tomcat7上运行Jenkins - Windows 7.我在jenkins配置中提供了节点bin路径。然后运行shell脚本,如下所示:
echo $PATH
node --version
npm install -g grunt-cli
npm install
grunt cssmin
正如其他帖子Jenkins integration with Grunt中所建议的那样,我已经多次重新启动了jenkins,并试图处理该帖子中写的所有答案,但仍显示错误,grunt:命令未找到。
来自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
我也遵循了本网站grunt-on-jenkins
中提到的步骤package.json和Gruntfile.js在我执行jenkins构建时第一次在根目录中,grunt从我的gruntfile.js安装了所有模块,之后在所有其他构建中显示了上面的输出。
任何人都可以在这里检查出现了什么问题。
答案 0 :(得分:1)
经过大量搜索后,我发现了我的咕噜声安装位置。就jenkins构建而言,它安装在drive:/.jenkins....../workspace/node_modules/.bin
。
使用shell脚本export path=$PATH:drive:/.jenkins....../workspace/node_modules/.bin
在jenkins中提供此路径后,grunt开始执行。
此外,我在此过程中学到的是检查系统路径上可执行文件的可用位置或jenkins所指的路径在没有qoutes的情况下使用which "executable_name"
。你可以在windows和linux上使用这个命令。例如:which grunt
将显示grunt可执行文件所在的路径。
答案 1 :(得分:0)
从错误信息看来,Sheel无法找到咕噜声。你可以检查它是否存在于$ PATH变量中。这个shell脚本在哪个节点上运行?您可以检查特定节点的$ PATH。您还可以在shell脚本中将$ grunt安装路径添加到$ PATH变量。
grunt_path="grunt_installtion_path"
export PATH=${PATH}:${grunt_path}