Deploy TestAgent fails with unhandled exception

2019-09-14 02:07发布

The Deploy test agent task in TFS release definition fails with the below exception:

Unhandled Exception: System.Management.Automation.PSInvalidOperationException: The WriteObject and WriteError methods cannot be called from outside the overrides of the BeginProcessing, ProcessRecord, and EndProcessing methods, and they can only be called from within the same thread. Validate that the cmdlet makes these calls correctly, or contact Microsoft Customer Support Services. 2017-06-16T08:49:49.9634068Z
at System.Management.Automation.MshCommandRuntime.ThrowIfWriteNotPermitted(Boolean needsToWriteToPipeline) 2017-06-16T08:49:49.9634068Z at System.Management.Automation.MshCommandRuntime.WriteHelper_ShouldWrite(ActionPreference preference, ContinueStatus lastContinueStatus) 2017-06-16T08:49:49.9634068Z at System.Management.Automation.MshCommandRuntime.WriteWarning(WarningRecord record, Boolean overrideInquire) 2017-06-16T08:49:49.9634068Z at System.Management.Automation.Cmdlet.WriteWarning(String text) 2017-06-16T08:49:49.9634068Z at Microsoft.TeamFoundation.DistributedTask.Task.DistributedTestAutomation.Logger.WriteWarning(String message) 2017-06-16T08:49:49.9634068Z at Microsoft.TeamFoundation.DistributedTask.Task.DistributedTestAutomation.TestAgentDownloader.wc_DownloadFileCompleted(Object sender, AsyncCompletedEventArgs e) 2017-06-16T08:49:49.9634068Z at System.Net.WebClient.OnDownloadFileCompleted(AsyncCompletedEventArgs e) 2017-06-16T08:49:49.9634068Z at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 2017-06-16T08:49:49.9634068Z at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 2017-06-16T08:49:49.9634068Z at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() 2017-06-16T08:49:49.9634068Z at System.Threading.ThreadPoolWorkQueue.Dispatch() 2017-06-16T08:49:55.4477257Z ##[error]PowerShell script completed with 255 errors.

The task executes successfully if the Update test agent check box is not checked. Solution mentioned here https://github.com/Microsoft/vsts-tasks/issues/2964 and https://social.msdn.microsoft.com/Forums/sqlserver/en-US/dae4c62d-cd23-40ad-83cf-2555d37c0bb9/test-agent-deployment-failing?forum=tfsbuild does not seems to work either

2条回答
狗以群分
2楼-- · 2019-09-14 02:29

The issue was resolved by downloading the testagent exe and copying the same to a share folder that has access to the build agents. This is configured under the advanced section and provide the share path under Test Agent Location.

enter image description here

查看更多
别忘想泡老子
3楼-- · 2019-09-14 02:45

Advanced - Update test agent

If set, and the test agent is already installed on the test machines, the task will check if a new version of the test agent is available.

  • First, check if the test agent is already intalled on the machines, if not this maybe the root cause.
  • Try to do the deploy test agent with same settings in the build definition instead of release. This will narrow down if the issue is only related to release or not.
  • Check the Even Log in the test agent machine if there are some useful info.
  • Try to deploy the test agent to another machine with old test agent installed and "update test agent" checked.

Besides, if you are using TFS2017 update2Rc and want to deploy latest test agent, suggest you to use Version 2. instead of 1. for the Visual Studio Test Agent Deployment task and try again.

查看更多
登录 后发表回答