Skip to content

fix: propagate maven exit code to just#137

Merged
eric-thelin merged 1 commit intomainfrom
fix/propagate-maven-exit-code-to-just
Mar 31, 2026
Merged

fix: propagate maven exit code to just#137
eric-thelin merged 1 commit intomainfrom
fix/propagate-maven-exit-code-to-just

Conversation

@eric-thelin
Copy link
Copy Markdown
Collaborator

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/

Checklist

  • Changes are limited to a single goal (avoid scope creep)
  • I confirm that I have read any Contribution and Development guidelines (CONTRIBUTING and DEVELOPMENT) and are following their suggestions.
  • I confirm that I wrote and/or have the right to submit the contents of my Pull Request, by agreeing to the Developer Certificate of Origin, (adding a 'sign-off' to my commits).

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>
@eric-thelin eric-thelin force-pushed the fix/propagate-maven-exit-code-to-just branch from fa1532b to 153686a Compare March 31, 2026 07:24
@eric-thelin eric-thelin merged commit bc36b58 into main Mar 31, 2026
16 checks passed
@eric-thelin eric-thelin deleted the fix/propagate-maven-exit-code-to-just branch March 31, 2026 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants