tag:help.appveyor.com,2012-11-13:/discussions/questions/18699-fail-build-on-upload-test-failAppVeyor: Discussion 2018-08-25T02:27:40Ztag:help.appveyor.com,2012-11-13:Comment/449743212018-03-26T21:01:58Z2018-03-26T21:01:58ZFail build on upload test fail.<div><p>I can be wrong, but doubt it actually works on local machine. Please see attached picture from my local machine. <code>& echo %ERRORLEVEL%</code> does not pick up exit code from the command before <code>&</code>. It probably uses code from previous script execution on your local machine.</p>
<p>I would recommend using PowerShell with <code>-ErrorAction</code> and <code>-ErrorVariable</code>. Some think like this (not exactly tested but you should get the idea):</p>
<pre>
<code>dir *.exe | % {& $_ -xunitxml >> testsResults.xml} -ErrorAction SilentlyContinue -ErrorVariable myError
ps: (new-object net.webclient).UploadFile("https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\testsResults.xml))
if ($myError) {throw $myError}</code>
</pre></div>Ilya Finkelshteyn