无法获取TeamCity Build步骤来执行grunt-cli [英] Cannot get TeamCity Build Step to execute grunt-cli
问题描述
我试图在TeamCity服务器上自动构建我的项目。我使用 grunt
定义和配置我的任务。这在本地工作很好。但是,我有TeamCity(在Windows Server 2008上运行)遇到问题,以识别 grunt
作为可执行文件,构建将失败, grunt
被调用,因为它不可用。
我在服务器上安装了 grunt-cli
并且可以在我通过ssh登录时执行它(当我以这种方式触发时,构建脚本也成功。)
我正在运行 npm install在我调用grunt之前,还尝试使用
预安装
指令强制安装 grunt-cli
在我的 package.json
如:
{
name:someName,
version:0.0.1,
private:true,
scripts:{
preinstall:npm安装grunt-cli -g
},
devDependencies:{
grunt:〜0.4.1,
grunt-contrib-jshint: 〜0.6.3,
grunt-contrib-less:〜0.8.1,
grunt-contrib-watch:〜0.5.3,
grunt -contrib-requirejs:〜0.4.1,
grunt-strip:〜0.2.1,
grunt-bump:0.0.11
}
}
我可以看到npm安装grunt-cli,但grunt不可用下一步。
我也尝试将它包装到 bat
文件中,或者使用多个构建步骤来安装和运行依赖关系
没有任何输入? p>我有在尝试让我们的TFS Build代理运行grunt-cli时遇到同样的问题< a>。最后我只是改变了我的构建过程,使用grunt-cli可执行文件的完整路径。
所以我改变了使用这个:
grunt deploy
这:
C:\Users\tfsservice\AppData\Roaming\\\
pm\grunt.cmd deploy
我知道这只是一个解决方法,而不是一个真正的修复,让你去。
我可以通过以下方式使其正常工作:
只需添加C:\Users\tfsservice\AppData\Roaming\\\pm(其中找到grunt.cmd文件)到我的系统路径,然后重新启动我的构建服务器。需要重新启动,因为tfsservice是用户和正在运行的服务;只是重新启动服务可能就足够了,但是我没有测试。
完成这个 grunt deploy 之后,
I'm trying to automate building of my project on a TeamCity server. I'm using grunt
to define and configure my tasks. This works fine locally. Yet, I am having problems getting TeamCity (running on Windows Server 2008) to recognize grunt
as a executable, the build will fail when grunt
is called as it is not available.
I do have grunt-cli
installed on the server and can execute it when I login via ssh (The build script also succeeds when I trigger it that way).
I'm running npm install
before I call grunt and also tried to force install grunt-cli
using a preinstall
instruction in my package.json
like:
{
"name": "someName",
"version": "0.0.1",
"private": true,
"scripts" : {
"preinstall" : "npm install grunt-cli -g"
},
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-jshint": "~0.6.3",
"grunt-contrib-less": "~0.8.1",
"grunt-contrib-watch": "~0.5.3",
"grunt-contrib-requirejs": "~0.4.1",
"grunt-strip": "~0.2.1",
"grunt-bump": "0.0.11"
}
}
I can see npm installing grunt-cli, yet grunt is not available in the next step.
I also tried wrapping that into a bat
file or using multiple build steps for dependency installing and running the grunt task.
Does anyone have any input on this?
I had the same problem when trying to get our TFS Build agents to run grunt-cli. In the end I just changed my build process to use the full path to the grunt-cli executable.
So I changed from using this:
grunt deploy
to using this:
"C:\Users\tfsservice\AppData\Roaming\npm\grunt.cmd" deploy
I know this is just a workaround and not a true fix, but it should be good enough to get you going. I hope this helps.
-- Update --
I was able to get it to work properly by simply adding "C:\Users\tfsservice\AppData\Roaming\npm" (where the grunt.cmd file is found) to my system path, and then rebooting my build server. The reboot was required since tfsservice is both a user and a running service; simply restarting the service may be enough, but I didn't test that.
After doing this grunt deploy worked in our builds as expected.
这篇关于无法获取TeamCity Build步骤来执行grunt-cli的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!