Fail build on upload test fail.
I'm running custom tests via the script:
for %%a in (*.exe) do (%%a -xunitxml >> testsResults.xml)
and then uploading them with
ps: (new-object net.webclient).UploadFile("https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\testsResults.xml))
So far, so good.
Now the problem comes from the fact that if one of the test exes fails then the build stops and the rest of the tests are not run.
What I want to do is to run all of the tests and then fail the build if any of them failed.
I tried:
set FailedTestsCount=0
for %%a in (*.exe) do (%%a -xunitxml >> testsResults.xml & set /a FailedTestsCount=%FailedTestsCount% + %ERRORLEVEL%)
if %FailedTestsCount% GTR 0 (exit 1) else (appveyor exit)
but, while it works when I test it in my cmd, %FailedTestsCount%
is always 0 when run on the server.
Any ideas?
Thanks in advance
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
1 Posted by Ilya Finkelshte... on 26 Mar, 2018 09:01 PM
I can be wrong, but doubt it actually works on local machine. Please see attached picture from my local machine.
& echo %ERRORLEVEL%
does not pick up exit code from the command before&
. It probably uses code from previous script execution on your local machine.I would recommend using PowerShell with
-ErrorAction
and-ErrorVariable
. Some think like this (not exactly tested but you should get the idea):Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 02:27 AM.