Whenever a certain condition holds true in the Execute shell of a Post-build step for a successful build, I want to trigger an email send. The problem is that, even when the condition doesn't hold true, the build is considered a success.
What I'm trying to implement:
if [condition == true]; then
<do some action1>
exit 0; //This success code should trigger email
else
<do different action2>
exit 0; //This success code should not trigger email
fi
The exit codes are 0 as both of the actions above are valid and it's a successful build. How do I send an email on success based on some criteria in Jenkins?