0

One of my Jenkins job is executing MSTest. I am passing the following command to Execute Windows batch command:

del TestResults.trx

"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\MSTest.exe" /testcontainer:D:\Projects\Jenkins\TestResultVerificationFromJenkins\TestResultVerificationFromJenkins\bin\Debug\TestResultVerificationFromJenkins.dll /resultsfile:TestResults.trx /nologo /detail:stdout

At the time of execution, Console Output is displaying the following values:

Starting execution... Results Top Level Tests ------- --------------- Passed TestResultVerificationFromJenkins.UnitTest1.PassTest [stdout] = Test is passed* 1/1 test(s) Passed

Summary

Test Run Completed. Passed 1


Total 1 Results file: C:\Program Files (x86)\Jenkins\jobs\JenkinsTestResultReader\workspace\TestResults.trx Test Settings: Default Test Settings

In the post build step, I have to pass the MS test result "Test is passed" to a HTTP Request.

Is there any way to save this result in a Jenkins variable so that I can pass that to HTTP Request?

Regards, Umesh

Umesh Chhabra
  • 49
  • 1
  • 3

1 Answers1

0

Since you are in the postbuild step, would parsing the console output for the test result and sending it off to the HTTP Request be an option for you?

For example, using Groovy Postbuild plugin, you could write a small script that could do this.

Perhaps something like:

if(manager.build.logFile.text.indexOf("Test Run Completed. Passed") >= 0)
   manager.listener.logger.println (new URL("http://localhost?parameter=Test+is+passed")).getText()
Daniel Omoto
  • 2,431
  • 17
  • 15
  • Thank you Daniel. I am thinking on the same lines but I am looking for a more graceful solution. I may need to write my own plugin which can return Detailed Result of a Jenkins Job and able to save the result in the variable. – Umesh Chhabra Aug 28 '16 at 18:24