Build not failing when tasks run using exec fails Thiyagu Palanisamy Updated September 27, 2016 18:27 Follow We are invoking "mvn test" using exec, build passes even when unit test fails. How do I fail the build? Comments 1 comment Sort by Date Votes Anandha Krishnan April 29, 2011 12:18 Go will fail the build if an "exec" task returns with a non zero code. Just make sure your maven target (I am guessing you are using the test target on a maven build) exectues and return with a non zero value.This is usually done using a failure property which is set in case the task fails. The Junit task in case of ant has a similar property.Also just make sure your maven target is not set to ignore this failure property. (This will casue the target to not fail inspite of test failures). 0 Comment actions Permalink Please sign in to leave a comment.