The environment STAGE_NAME variable does not persist when the stage ends prematurely. here's an example:
While it makes sense for STAGE_NAME to be null when not in an actual stage, it would be nice if we had a build property or environment variable such as LAST_STAGE_NAME which would keep the last stage executed. This functionality is critical to my shared library logic in which I have a generic script runner and I want to know at which stage the script it ran failed (without having to modify each flow).
It would also be useful if this property would be available when calling getBuildVariables() on a downstream job started by the build step.