TFS Build找不到Grunt [英] TFS Build cannot find Grunt

查看:106
本文介绍了TFS Build找不到Grunt的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我们的TFS构建服务器上安装了npm和grunt.我使用 npm install -g grunt-cli 安装了grunt-cli,然后以自己的身份登录时可以从命令行运行 grunt deploy .

I have installed npm and grunt on our TFS build server. I installed the grunt-cli using npm install -g grunt-cli and was then able to run grunt deploy from the command line when logged in as myself.

Out TFS构建以 tfsservice 用户身份运行,当尝试进行 grunt部署时,它会收到一条错误消息:

Out TFS builds run as the tfsservice user though, and when it attempts to do grunt deploy it gets an error message that:

'grunt' is not recognized as an internal or external command, operable program or batch file.

因此,当我以自己的身份登录构建服务器时,如果我以 tfsservice 的身份运行命令提示符,则会遇到相同的错误.因此,我尝试从该命令提示符执行 npm install -g grunt-cli ,它看起来已正确安装并在C:\ Users \ tfsservice \ AppData \ Roaming \ npm中创建了grunt文件,但是然后在运行 grunt deploy 时仍然会遇到相同的错误.

So, while logged in as myself on the build server, if I run the command prompt as tfsservice I get the same error. So I tried doing npm install -g grunt-cli from that command prompt, and it looked to have installed properly and created the grunt files in C:\Users\tfsservice\AppData\Roaming\npm, but then I still get the same error when running grunt deploy.

看起来好像没有为 tfsservice 安装grunt-cli吗?当我获得tfsservice%homepath%时,我看到它被设置为 \ Windows \ system32 ,而不是预期的 \ Users \ tfsservice ;也许这与服务帐户有关吗?

So it looks like grunt-cli is not getting installed for tfsservice? When I get the tfsservice %homepath% I see that it is set to \Windows\system32, rather than the expected \Users\tfsservice; maybe it being a service account has something to do with it?

我看到使用了类似的问题与Team City一起使用grunt-cli ,但建议使用特定于Team City的插件.

I see that a similar questions has been asked for using grunt-cli with Team City, but it recommends using a Team City specific plugin.

还有这篇文章,他们说他们改变了Team City的运行方式不同的用户,然后一切都开始正常工作.改变我们的版本,使其以不同于 tfsservice 的用户身份运行对我来说不是真正的选择.

There's also this post which says they changed Team City run as a different user and then everything just started working properly. Changing our builds to run as a different user than tfsservice isn't really an option for me though.

任何建议都值得赞赏.谢谢.

Any suggestions are appreciated. Thanks.

推荐答案

tfsservice 登录并运行 npm install -g grunt-cli 后,它将所有 C:\ Users \ tfsservice \ AppData \ Roaming \ npm 中的文件,但找不到 C:\ Users \ tfsservice \ AppData \ Roaming \ npm \ grunt.cmd 文件,直到将 C:\ Users \ tfsservice \ AppData \ Roaming \ npm 添加到系统路径;您也许可以只为tfsservice用户的变量创建一个新的Path变量,但是我希望它也可以在以其他用户身份登录时工作.

After logging in as tfsservice and running npm install -g grunt-cli it placed all of the grunt files in C:\Users\tfsservice\AppData\Roaming\npm, but it couldn't find the C:\Users\tfsservice\AppData\Roaming\npm\grunt.cmd file until I added C:\Users\tfsservice\AppData\Roaming\npm to the System Path; you might be able to get away with creating a new Path variable for just the tfsservice user's variables, but I wanted it to work when logged in as other users too.

当我以tfsservice手动登录并打开新的命令提示符后,一旦执行 grunt deploy 便可以正常工作,但是当实际的TFS Build以tfsservice的形式进行构建时,仍然无法正常工作.首先,我只是修改了构建过程,以使用完整路径从命令行调用grunt.cmd,如下所示:

Once I did that grunt deploy worked when I was manually logged in as tfsservice and opened a new command prompt, but still wouldn't work when the actual TFS Build performed the build as tfsservice. At first I just modified my build process to call grunt.cmd from the command line by using its full path, like so:

"C:\Users\tfsservice\AppData\Roaming\npm\grunt.cmd" deploy

,并确保我在所有构建机器上以tfsservice的身份运行 npm install -g grunt-cli ,以确保grunt存在于每个构建服务器上的tfsservice用户的AppData目录中.这行得通,但更多的是解决方法,而不是修复程序.

and made sure that I ran npm install -g grunt-cli as tfsservice on all of my build machines to make sure grunt exists in the tfsservice user's AppData directory on each build server. This worked, but was more of a workaround than a fix.

结果证明,最后一步是我只需要重新启动TFS Build服务器.一旦我完成了 grunt deploy 的工作,就可以按预期的那样工作,因此,我不再需要指定完整路径了:)只需重新启动tfsservice可能就足够了,但是我只是将PC重新引导至保持安全.

Turns out the final step was I just had to reboot the TFS Build server. Once I did that grunt deploy worked as expected for the builds, so I didn't need to specify the full path anymore :) Simply restarting the tfsservice might have been enough, but I just rebooted the PC to be safe.

这篇关于TFS Build找不到Grunt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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