Monday, April 18, 2016

Test agent 2013: The setup batch file exited with error code 1


Hi. Today I want show you how resolve errors connect with execute batch file in deploy step before
execute tests.

So in my case I have:
  1. TFS 2015
  2. Test Controller 2013
  3. Test Agent 2013
  4. Microsoft Test Manager.
 Imagine, that you have task execute tests before execute tests. You write this script and put it to Microsoft test manager in (Advance -> Scripts).

This scripts you shouldn't put to test agent!
If you write path: C:\temp\test.bat
You should put to temp folder put test.bat file.
After that you want try execute test, and you see error:

TestOutcome 'Error'; Message 'The setup batch file exited with error code 1
Standard Console Output:
C:\Users\***\AppData\Local\VSEQT\QTAgent\***\***\Deployment>REM ****************************************************************************
C:\Users\***\AppData\Local\VSEQT\QTAgent\***\***\Deployment>REM *  Generated by Microsoft Visual Studio
C:\Users\***\AppData\Local\VSEQT\QTAgent\***\***\Deployment>REM *  Copyright (c) Microsoft Corporation. All rights reserved.
C:\Users\***\AppData\Local\VSEQT\QTAgent\***\***\Deployment>REM *  
C:\Users\***\AppData\Local\VSEQT\QTAgent\***\***\Deployment>REM ****************************************************************************
C:\Users\***\AppData\Local\VSEQT\QTAgent\***\***\Deployment>set DeploymentDirectory=C:\Users\***~1\AppData\Local\VSEQT\QTAgent\***\***-~1.COM\DEPLOY~1
C:\Users\***\AppData\Local\VSEQT\QTAgent\***\***\Deployment>set BuildDirectory=\\X.X.X.X\***
C:\Users\***\AppData\Local\VSEQT\QTAgent\***\***\Deployment>set TestRunDirectory=C:\Users\***~1\AppData\Local\VSEQT\QTAgent\***\***-~1.COM
C:\Users\***\AppData\Local\VSEQT\QTAgent\***\***\Deployment>set TestRunResultsDirectory=C:\Users\***~1\AppData\Local\VSEQT\QTAgent\***\***-~1.COM\Results\***-~1.COM
C:\Users\***\AppData\Local\VSEQT\QTAgent\***\***\Deployment>set TotalAgents=1
C:\Users\***\AppData\Local\VSEQT\QTAgent\***\***\Deployment>set AgentWeighting=100
C:\Users\***\AppData\Local\VSEQT\QTAgent\***\***\Deployment>set AgentLoadDistributor=Mic"

So in my case my batch file execute powershell script:

 Powershell.exe -command "C:\Temp\test.ps1" -parameter "someValue"


This issue connect with execution policy. You can add this parameter, and this is fix issue:


Powershell.exe -executionpolicy remotesigned -command "C:\Temp\test.ps1" -parameter "someValue"


1 comment: