SharpeRAD / Cake.Powershell

Powershell addin for Cake
http://cakebuild.net
MIT License
83 stars 36 forks source link

How to detect a successful run? #17

Closed avishnyakov closed 7 years ago

avishnyakov commented 7 years ago

Hey, great additon to Cakebuild. Using it with Pester post-build regression, completely love it.

However, not too sure on how to detect a successful outcome of StartPowershellFile(). Docs say it returns an array of PSObject, so.. what would be the easiest way to detect if StartPowershellFile had an exception or something?

DixonDs commented 7 years ago

I have a similar question regarding StartPowershellScript. I see the following line in the console output which says that an error occurred:

Exception of type 'System.Exception' was thrown

But the build is not failed. I would like to have the build failed in this case and also print exception details.

SharpeRAD commented 7 years ago

Alter your Powershell script to return a custom value, parse the PsObject in Cake and throw an exception in Cake based on its value.

Found a link on StackOverflow that will give you a starting point. If you get it working can you add it to the example script for others to follow.