-
-
Notifications
You must be signed in to change notification settings - Fork 624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow defer
to know if the task succeded or failed
#1484
Comments
@andreynering Could you explain a bit deeper how you would the yml to be?
making it very similar to the regular defer, but a bit different from what @your-diray suggested |
@dorimon-1 As for your suggestion, if we add Personally I prefer
in the OP though, because no new syntax is needed: version: "3"
#This should be automatically set.
env:
DEFER_EXIT_STATUS: 0
tasks:
default:
cmds:
- defer: |
if test ${DEFER_EXIT_STATUS} == 0; then
echo success
else
echo failure
fi |
Exactly what I have been searching for. I think @dorimon-1 idea looks neat and allows for backward compatibility with regular defer. |
This was just implemented on #1762. |
Originally asked in #1472 by @your-diary.
A possible way to allow this is to expose one/some variables to
defer
. One possibility is to expose aDEFER_EXIT_CODE
var which would contain0
for success or the exit code of the task that failed.Perhaps we could also have
DEFER_SUCCESS
(true/false) andDEFER_FAIL
(true/false) to make a simpler check easier? (Not sure,DEFER_EXIT_CODE
is probably enough).The text was updated successfully, but these errors were encountered: