简体   繁体   English

TFS2012 LabDefault.11模板部署脚本因“ Team Foundation Server无法完成部署任务”而失败

[英]TFS2012 LabDefault.11 template deploy scripts fail with “Team Foundation Server could not complete the deployment task”

I am having security issues with lab management and standard environments. 我在实验室管理和标准环境中遇到安全问题。

I have TFS2012 update 2 installed in my domain "DevDomain". 我在域“ DevDomain”中安装了TFS2012更新2。 I have a separate build/lab machine also in "DevDomain" on which both a build controller, build agents and a test controller for the same collection "CollectionA" are installed. 我还在“ DevDomain”中有一台单独的构建/实验室机器,在该机器上安装了同一集合“ CollectionA”的构建控制器,构建代理和测试控制器。

Automated builds work just perfectly. 自动化构建工作完美。

I have deployment target PCs in "DevDomain" and in "TestDomain" (more on that later). 我在“ DevDomain”和“ TestDomain”中有部署目标PC(稍后会详细介绍)。

To take this to the next level, I want to now automatically deploy the TFS build agent constructed software to test rig machines; 为了使它更上一层楼,我现在想自动部署TFS构建代理构建的软件来测试钻机。 specifically I want to have a deployment script uninstall the existing product, copy the updated installer onto the target PC and then install it. 特别是我想让部署脚本卸载现有产品,将更新的安装程序复制到目标PC上,然后安装它。

My first foray was to define a standard environment in my "DevDomain" and get the deployment part of a lab build working within the same domain. 我的第一个尝试是在“ DevDomain”中定义一个标准环境,并在同一域中获得实验室构建的部署部分。

This worked. 这工作了。 Here is what I did; 这是我所做的;

The automated build (using the DefaultTemplate.xaml process) creates a MSI file I want to use for the deployment, and a PowerShell script which I want to run to orchestrate the deployment. 自动生成(使用DefaultTemplate.xaml进程)将创建要用于部署的MSI文件以及要运行以协调部署的PowerShell脚本。 (the script simply attempts to run the MSI via msiexec to uninstall, copy the new version locally then run it via msiexec to install the new copy). (脚本只是尝试通过msiexec运行MSI进行卸载,在本地复制新版本,然后通过msiexec运行它来安装新副本)。 The automated build happily makes both these artefacts and puts them in the defined TFS drop share. 自动化构建很高兴地做出了这两个伪像,并将它们放入定义的TFS丢弃份额中。

In order to go about this I have: 为了做到这一点,我有:

  • Created a new standard lab environment with a single machine (desktop client role) 用一台机器创建了一个新的标准实验室环境(桌面客户端角色)
    • The lab manager successfully deployed the agent to this PC 实验室管理员已成功将代理部署到此PC
    • the agent is running interactive and showing its online. 该代理正在交互运行并在线显示。
  • Created a new build definition using the LabDefaultTemplate.11.xaml workflow. 使用LabDefaultTemplate.11.xaml工作流程创建了一个新的构建定义。
    • referenced the above lab in the configuration 在配置中引用了上述实验室
    • referenced the latest output of the automated build in config 引用了config中自动构建的最新输出
    • specified the build output PowerShell script (via the $(BuildLocation) macro. 通过$(BuildLocation)宏指定了构建输出PowerShell脚本。

This deploy tab of the build specifies the following script to be run on the machine sin the lab with "Desktop Client" role: 构建的此部署选项卡指定以下脚本在实验室中以“ Desktop Client”角色运行在计算机上:

cmd /c powershell.exe "$(BuildLocation)\DeployGuiToLabWorkstation.ps1" "$(BuildLocation)"

This works. 这可行。

Note that I am configuring test agents to run as interactive processes as my ultimate aim after the deployment works is to drive coded UI tests on these labs. 请注意,在部署工作之后,我将测试代理配置为以交互过程的形式运行,这是我最终的目标是在这些实验室中驱动编码的UI测试。

The problems start when trying to deploy to a machine in a different domain Now to make this more realistic I now need to define a standard lab environment for my QA machines, which are in a different domain; 当尝试将其部署到不同域中的机器时,问题就开始了。为了使其更加现实,现在我需要为我的QA计算机定义一个标准实验室环境,这些机器位于不同域中。 "TestDomain". “TESTDOMAIN”。

The domain "TestDomain" has a trust relationship with the domain "DevDomain". 域“ TestDomain”与域“ DevDomain”具有信任关系。 There is no reciprocal trust between "DevDomain" and "TestDomain" “ DevDomain”和“ TestDomain”之间没有相互信任

Again the test manager lab centre defined this OK and deployed the agent, and the agent reported itself online to my test controller. 测试经理实验室中心再次定义了此OK,并部署了代理,代理将自己在线报告给我的测试控制器。

Now when I change the lab build to reference the new standard environment (on "TestDomain") the deployment fails with this error; 现在,当我更改实验室版本以引用新的标准环境(在“ TestDomain”上)时,部署失败并显示此错误;

Exception Message: Team Foundation Server could not complete the deployment task for
machine '10.7.70.71', script 'cmd' and arguments '/c copy \\*buildmachine*
\TFS_Drop\...\DeployGuiToWorkstation.ps1 C:\GuiDeploy'. (type LabDeploymentProcessException)

In order to diagnose this I have modified the lab deploy script to be: 为了诊断这一点,我将实验室部署脚本修改为:

"cmd /c powershell whoami"

And according to the logs the process is being run as "nt authority\\system" and not the account the lab environment specified for the test agent. 并且根据日志,该进程将以“ nt Authority \\ system”(而不是为测试代理程序指定的实验室环境)帐户运行。

This explains the script error; 这解释了脚本错误; PowerShell on the target PC cannot access the TFS drop share, but since this account is a local machine account I cant possibly grant permissions to the machine account of a PC in "TestDomain" to a share and NTFS folder on a machine in "DevDomain" 目标PC上的PowerShell无法访问TFS删除共享,但是由于该帐户是本地计算机帐户,因此我可能无法将“ TestDomain”中PC的计算机帐户的权限授予“ DevDomain”中计算机的共享和NTFS文件夹

So how can I grant permissions on the "devDomain" share/filesystem to a "System" service account from a machine in "TestDomain"? 那么,如何从“ TestDomain”中的计算机向“ System”服务帐户授予“ devDomain”共享/文件系统上的权限?

or 要么

How do I get the test agent (running as a local machine administrator) to execute the deployment script in its own account context rather then this machine system context? 如何获得测试代理(以本地计算机管理员身份运行)以在其自己的帐户上下文而不是此计算机系统上下文中执行部署脚本?

I am stumped! 我很沮丧!


EDIT : It seems that the test agent UI runs in the account you specify, but when you configure it that way it leaves the service "Visual Studio Lab Agent Service" running as local system, you can manually change this in services, to a more appropriate domain account and that account is then reflected in the PS "whoami" results. 编辑 :似乎测试代理UI在您指定的帐户中运行,但是以这种方式配置它时,它将使服务“ Visual Studio Lab代理服务”作为本地系统运行,您可以在服务中手动将其更改为更多适当的域帐户,然后将该帐户反映在PS“ whoami”结果中。

I am now investigating using a TestDomain account for the service that mirrors a "DevDomain" account so I can set share permissions appropriately. 我现在正在研究使用TestDomain帐户来镜像“ DevDomain”帐户的服务,以便我可以适当地设置共享权限。


This is a similar scenario to TFS Lab management Deployment Scripts but since that was side-stepped by using tests and test settings, and I specifically want a resolution of the deploy part I thought it worth asking the question. 这与TFS实验室管理部署脚本类似,但是由于使用测试和测试设置已绕开了这一步,所以我特别希望对部署部分进行解析,我认为值得提出这个问题。

The above Pete Stensønes' solution works on my conditions. 上面PeteStensønes的解决方案适用于我的条件。

But my scenario is to setup standard env on workgroup, but the tfs is in another domain. 但是我的情况是在工作组上设置标准环境,但是tfs在另一个域中。 Just list my steps for your reference: Create local account on the following server: local lab service account - tfslab 只需列出我的步骤以供参考:在以下服务器上创建本地帐户: 本地实验室服务帐户-tfslab

  1. tfs test controller server : create local tfslab account. tfs测试控制器服务器 :创建本地tfslab帐户。 Also configure the tfslab as lab service account in test controller configure console 在测试控制器配置控制台中还将tfslab配置为实验室服务帐户
  2. tfs test agent server : create local tfslab account and add tfslab to local admin group. tfs测试代理服务器 :创建本地tfslab帐户并将tfslab添加到本地管理组。 Also update Visual Studio Test Agent service and Visual Studio Lab Agent Service to run as tfslab. 还要更新Visual Studio测试代理服务和Visual Studio Lab代理服务,以tfslab的身份运行。
  3. tfs drop folder server : create local tfslab account. tfs投递文件夹服务器 :创建本地tfslab帐户。 And add share read permission to tfs drop folder. 并将共享读取权限添加到tfs投递文件夹。

Have you configured your test controller for using lab service account ? 您是否已配置测试控制器以使用实验室服务帐户

If not try this: 如果没有尝试,请执行以下操作:

在此处输入图片说明

Use account with appropriate permissions. 使用具有适当权限的帐户。

This account will be used to access to the build drop location, see 此帐户将用于访问构建放置位置,请参阅

C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\QTController.exe.config

and search for "UseLabServiceAccountToAccessBuildDirectory". 并搜索“ UseLabServiceAccountToAccessBuildDirectory”。

OK I have eventually solved this with a little help from our network support chaps. 好的,我最终在网络支持团队的帮助下解决了这个问题。

I require the agents on my "TestDomain" to be configured as interactive (as my next step is to run coded UI tests) when you do this, specifying a test lab account for communications, but a machine or domain account (in the "TestDomain") as the agent account (either being members of the local machine Administrators group) then the MTM lab process in "DevDomain" can deploy and configure successfully to the test machine in "TestDomain". 执行此操作时,我要求将“ TestDomain”上的代理配置为交互式(因为下一步是运行编码的UI测试),同时指定用于通信的测试实验室帐户,但要指定计算机或域帐户(在“ TestDomain”中)作为代理帐户(属于本地计算机Administrators组的成员),则“ DevDomain”中的MTM实验过程可以成功地部署和配置到“ TestDomain”中的测试计算机。

However this leaves the "Visual Studio Lab Agent Service" on the target machine in "testDomain" running as local system which is the process that actually executes your deployment script. 但是,这会使“ testDomain”中的目标计算机上的“ Visual Studio Lab代理服务”作为本地系统运行,而这实际上是执行部署脚本的过程。

I could not find a permutation in the test machines "Test agent configuration" tool that let me change this whilst still running the agent as interactive, but you can just change the logon information for the service with the services control panel applet. 我无法在测试计算机的“测试代理程序配置”工具中找到一个排列,可以让我在仍然以交互方式运行代理程序的同时进行更改,但是您可以使用服务控制面板小程序来更改服务的登录信息。

What I did was: 我所做的是:

  • Create a "test agent" local account on the "TestDomain" target machine and added that to the "TestDomain" target machine's local administrators group. 在“ TestDomain”目标计算机上创建一个“测试代理” 本地帐户 ,并将其添加到“ TestDomain”目标计算机的本地管理员组中。

  • I then mirrored this by creating a machine local account with the same name and password on the machine hosting our TFS drop share. 然后,我通过在托管我们的TFS投递共享的计算机上创建一个具有相同名称和密码的计算机本地帐户来对此进行镜像

  • I then granted read access to the share and file-system to that local account. 然后,我向该本地帐户授予了对共享和文件系统的读取访问权限。

Now when the "devDomain" TFS server initiates aa build the script execution is run by the local "Visual Studio Lab Agent Service" its in the context of the new local "test agent" account and since there is a matching local account on the machine hosting the share it gets permissions granted, the share is readable, and hey presto it can run my script. 现在,当“ devDomain” TFS服务器启动并构建时,脚本执行由本地“ Visual Studio Lab代理服务”运行,它在新的本地“测试代理”帐户的上下文中运行,并且由于计算机上存在匹配的本地帐户托管共享时,它会被授予权限,共享是可读的,并且嘿,它可以运行我的脚本。

I have a workgroup environment without a domain, and it turns out that I had created the local account (.\\tfslab) and had the TFS Test Controller setup with the use this account for lab management (.\\tfslab) but I had forgotten to set each of the test agents services to run under the local machine account. 我有一个没有域的工作组环境,事实证明我已经创建了本地帐户(。\\ tfslab),并使用此帐户进行实验室管理(。\\ tfslab)来设置了TFS测试控制器,但是我忘记了将每个测试代理服务设置为在本地计算机帐户下运行。

To troubleshoot this issue I highly recommend changing the ' Deployment script and arguments ' to the following command: 要解决此问题,我强烈建议将“ Deployment script and arguments ”更改为以下命令:

cmd /c whoami cmd / c whoami

See additional troubleshooting steps here: http://social.msdn.microsoft.com/Forums/vstudio/en-US/f46dc491-87c2-4234-8566-99b25302020e/deployment-tasks-run-under-nt-authoritysystem?forum=tfsbuild 请参阅此处的其他疑难解答步骤: http : //social.msdn.microsoft.com/Forums/vstudio/en-US/f46dc491-87c2-4234-8566-99b25302020e/deployment-tasks-run-under-nt-authoritysystem?forum= tfsbuild

For folks who are running into issues with workgroup configurations ( non-Domain ) in the future don't forget to update the following services such that: 对于将来遇到工作组配置( 非域 )问题的人们,请不要忘记更新以下服务,例如:

The Visual Studio Lab Agent Service ' Log On Account ' is changed from ' local system account ' to ' This Account ' and specify the local machine account ' .\\tfslab ' Visual Studio Lab代理服务的登录帐户 ”从“ 本地系统帐户 ”更改为“ 此帐户 ”,并指定了本地计算机帐户“ 。\\ tfslab

The Visual Studio Lab Network Agent Service ' Log On Account ' is changed from ' local system account ' to ' This Account ' and specify the local machine account ' .\\tfslab ' Visual Studio Lab网络代理服务的登录帐户 ”从“ 本地系统帐户 ”更改为“ 此帐户 ”,并指定本地计算机帐户“ 。\\ tfslab

Using Visual Studio 2012 Update 4, and Team Foundation Server, on a one-way trust or isolated/workgroup network configuration, we have found an additional step is required. 在单向信任或隔离/工作组网络配置上使用Visual Studio 2012 Update 4和Team Foundation Server,我们发现还需要执行其他步骤。 When running automated unit tests via the Build-Deploy-Test workflow, we have found that setting the lab service account is only part of the solution. 通过Build-Deploy-Test工作流程运行自动化单元测试时,我们发现设置实验室服务帐户只是解决方案的一部分。 In order to avoid Access is denied errors in the build, we also had to set the user for the Visual Studio Lab Agent Service. 为了避免生成中拒绝访问错误,我们还必须为用户设置Visual Studio Lab代理服务。

This is what the services in the Services applet look like after setting the lab service account (in this example, ".\\LabAdmin"): 设置实验室服务帐户(在本示例中为“。\\ LabAdmin”)后,服务小程序中的服务如下所示:

Visual Studio Lab Agent Service         | Configures, monitors... | Running | Automatic | Local System  
Visual Studio Lab Network Agent Service | Sets network propert... | Running | Automatic | Local System  
Visual Studio Test Agent                | Provides distributed... | Running | Automatic | .\LabAdmin  

In order to fix the Access is denied error, we also had to run the Visual Studio Lab Agent Service under the lab service account: 为了解决“访问被拒绝”错误,我们还必须在实验室服务帐户下运行Visual Studio实验室代理服务:

Visual Studio Lab Agent Service         | Configures, monitors... | Running | Automatic | .\LabAdmin  
Visual Studio Lab Network Agent Service | Sets network propert... | Running | Automatic | Local System  
Visual Studio Test Agent                | Provides distributed... | Running | Automatic | .\LabAdmin  

After making this change, and restarting the services, the Access is denied error went away. 进行此更改并重新启动服务后,“拒绝访问”错误消失了。 This was repeated on two different target computers, at least with our configuration it appears to be a necessary step. 至少在我们的配置中,这是在两台不同的目标计算机上重复进行的,这似乎是必要的步骤。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在流程模板中添加查询到团队收藏夹 - TFS2012 - Add Queries to Team Favourites in the Process Template - TFS2012 TFS 2012不会将TFS服务器添加到“ Team Foundation Server列表” - TFS 2012 does not add TFS server to “Team Foundation Server list” Team Foundation Server(TFS)的最佳选择,可以对项目进行完整的品牌重塑 - Team Foundation Server (TFS) Best Option for complete rebrand of project 新团队项目中的TFS2012 wiki.htm文件 - TFS2012 wiki.htm file in new team project 如何使用TFS Integration Platform,TFS2012到TFS2012将团队项目从一个集合复制到另一个集合 - How to copy a team project from one collection to another with TFS Integration Platform, TFS2012 to TFS2012 如果代码覆盖率低于TFS2012中的阈值,则构建失败 - Fail a build if code coverage is below a threshold in TFS2012 TFS 2012 RC - TF237165:由于服务器上的验证错误,Team Foundation无法更新工作项。 这可能是因为 - TFS 2012 RC - TF237165: Team Foundation could not update the work item because of a validation error on the server. This may happen because the TFS2012-新任务-“分配给”显示项目外部的人员 - TFS2012 - New Task - “Assigned To” shows people outside the project Team Foundation Server 2012还原 - team foundation server 2012 restore Team Foundation Server 2012和GIT - Team Foundation Server 2012 and GIT
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM