Continue rake after failure

I run rake to automate the build process inside CCNet. I use it to start IIS Express, then start Nunit, and then shut down the server after Nunit completes. The problem is that every time Nunit fails, the rake stops and never goes off. How to continue the rake after Nunit has failed, and still tells CCNet that Nunit has failed, and therefore has a build?

+6
source share
2 answers

How do you run NUnit from rake? do you use "sh"?

This is how you use "sh" to execute a shell command and intercept the result.

I just use an empty block to ignore any result (unsuccessful or successful)

sh "your shell command" do |ok,res| #empty block to ignore any failed or success status #in your case set failed flag based on ok parameter nunitSuccessFlag=false #hardcoded for sample; must set true or false based on ok parameter end 

puts this exception when shutting down the server, so ccnet knows that the build failed

  raise "NUnit failed" if nunitSuccessFlag == false 

alternative: use the try catch block as specified by the user above, as shown in this link: Rake Task: error handling (shut down the server in the provisioning block)

+6
source

I used this to make rake ignore the status returned from the command:

 sh "the command || true" 

true always exits without errors, making sh always see success.

+2
source

Source: https://habr.com/ru/post/909572/


All Articles