Is there a way to run a command if and only if my build tests fail?
This is not supported out of the box, if your tests fail and return a non zero exit code the entire build stops.
What you could do is wrap your entire test suite in a simple script that checks for the success or failure, and then fires off your command in the event of failure. As long as that script returns a zero exit code, then the entire build will pass.
Just to be explicit, that means the
test: post: command runs after every build right?
@levlaz I think this would be useful, having specific hooks for
after_success. These seem like very common operations to me.
I’d love to see something like:
test: after_success: - "sh beer.sh" after_fail: - "sh more-hacking.sh"
Run commands on success or failure
This is a great idea, I made this a feature request Run commands on success or failure, be sure to show your support for this feature by clicking on the heart.