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

查看:26
本文介绍了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.

虽然 TFS 构建以 tfsservice 用户身份运行,但当它尝试执行 grunt deploy 时,会收到一条错误消息:

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 fsserviceAppDataRoaming pm 中创建了 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 fsserviceAppDataRoaming pm, but then I still get the same error when running grunt deploy.

所以看起来 grunt-cli 没有为 tfsservice 安装?当我得到 tfsservice %homepath% 时,我看到它被设置为 Windowssystem32,而不是预期的 Users fsservice;也许它是一个服务帐户与它有关?

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 Windowssystem32, rather than the expected Users fsservice; maybe it being a service account has something to do with it?

我看到 一个类似的问题已经被要求使用grunt-cli 与 Team City 一起,但它建议使用 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.

还有这篇文章 说他们改变了团队城市运行不同的用户,然后一切都刚刚开始正常工作.不过,将我们的构建更改为以与 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 fsserviceAppDataRoaming pm 中的 grunt 文件,但找不到 C:Users fsserviceAppDataRoaming pmgrunt.cmd 文件,直到我将 C:Users fsserviceAppDataRoaming pm 添加到系统路径;您也许可以只为 tfsservice 用户的变量创建一个新的 Path 变量,但我希望它也能在以其他用户身份登录时工作.

After logging in as tfsservice and running npm install -g grunt-cli it placed all of the grunt files in C:Users fsserviceAppDataRoaming pm, but it couldn't find the C:Users fsserviceAppDataRoaming pmgrunt.cmd file until I added C:Users fsserviceAppDataRoaming pm 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 构建以 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	fsserviceAppDataRoaming
pmgrunt.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天全站免登陆