fix: propagate maven exit code to just#137
Merged
eric-thelin merged 1 commit intomainfrom Mar 31, 2026
Merged
Conversation
ChristofferKillander
approved these changes
Mar 31, 2026
Our maven commands are executed inside a separate bash shell. In order to propagate the exit status to just we need to set the `-e` flag. For good measure we include the whole 'strict mode' setting. set -euo pipefail This ensures that the maven exit code is properly propagated to the invoking shell and enables command chaining based on the outcome, i.e. just test; and echo success; or echo failure Without the fix, the command above would always print 'success' regardless of whether or not there are any test failures. With the fix, it would print 'success' if, and only if, all tests pass and 'false' otherwise. One way to take advantage of this is to conditionally push your changes when all automated checks are successful: just test; and just verify; and git push The command above will only push the local changes when all tests and all linter checks pass. Without the fix, the test step have no impact on the push and you stand the risk of pushing changes with test failures. See: http://redsymbol.net/articles/unofficial-bash-strict-mode/ Signed-off-by: Eric Thelin <extern.eric.thelin@digg.se>
fa1532b to
153686a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Our maven commands are executed inside a separate bash shell. In order to propagate the exit status to just we need to set the
-eflag. For good measure we include the whole 'strict mode' setting.This ensures that the maven exit code is properly propagated to the invoking shell and enables command chaining based on the outcome, i.e.
Without the fix, the command above would always print 'success' regardless of whether or not there are any test failures. With the fix, it would print 'success' if, and only if, all tests pass and 'false' otherwise.
One way to take advantage of this is to conditionally push your changes when all automated checks are successful:
The command above will only push the local changes when all tests and all linter checks pass. Without the fix, the test step have no impact on the push and you stand the risk of pushing changes with test failures.
See: http://redsymbol.net/articles/unofficial-bash-strict-mode/
Checklist