[this intelligent life]

Blog Post

How to make a Jenkins powershell script fail

Mark Wojciechowicz • Jun 30, 2017

Jenkins (the CI server) has a myriad of plugins, one of which is for executing powershell scripts. I rely on powershell heavily because I find a number of the other add-ins very limiting. In this particular case, I needed to run nunit tests and I needed the job to fail when the tests fail. I'll post more on the nunit thing at a later date, for which this is a plugin but it won't work for database projects.

When the powershell script throws an error, the build just writes the error to the log and keeps chugging along. The magic button to make the build fail is to add this to the top of the script:

$ErrorActionPreference = "Stop" 

And Bam! Rainy days again!


Share by: