When using the extra “OnFailure” stage and having the first stage successful - the entire build evaluates as not successful because the gate to the next step is failing its condition
“$Stage.IsSuccessful$ does not equal “True”” - this evaluates to false and thus:
“The following Stage Gate Condition failed:
The expression [’$Stage.IsSuccessful$’ does not equal ‘True’] evaluated to False. ‘True’ equals ‘True’.”
Due to this message - The “OnFailiure” Stage Gate Condition failure to match the previous stage `$Stage.IsSuccessful$ to True - The entire build seems to be marked as failed.
But regardless of that, I am trying to use try-catch instead of a separate stage as you suggested because this idea does seems more logical to me - but there’s something strange going on:
Under “catch” I set the build version format string to “Build Failed!” and set a “FinalBuilderFailed” variable to “Failed” and just below that (outside the “Catch” clause) -
I have an if condition to check if indeed “FinalBuilderFailed” variable evaluates to “Failed” - if it does - then it runs a “Stop” action that should mark the stage and build as a failure.
What actually happens is:
FB8 Run fails (I cause this deliberately by passing a non-existing git branch to FB8 to deploy from)
The “Build Version” is updated to “Build Failed!” (as expected, 1st nested command under “Catch”)
“FinalBuilderFailed” variable is set to “Failed” (as expected, 2nd nested command under “Catch”)
If clause checks if “Failed” is listed under “FinalBuilderFailed” variable and if so calls “Stop” action which is set to “Stage and build as failure”
BUT the “Build Version” (the same one that says “Build Failed” is in green… because somehow the build evaluates as successful even though the “Stop” action should have marked both stage+build as failures.
attaching screenshots of the stage setup and of a failed build to illustrate: