Skip to content

Instantly share code, notes, and snippets.

@swarawan
Last active March 1, 2021 03:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swarawan/d28ebf8655ef9690792678de5c84cc64 to your computer and use it in GitHub Desktop.
Save swarawan/d28ebf8655ef9690792678de5c84cc64 to your computer and use it in GitHub Desktop.
Git pre-commit hook to run maven test
echo "========== Hook: Run Maven Test =========="
# run maven test
mvn clean test
if [ $? -ne 0 ]; then
echo "========= Hook: Error While Testing The Code =========="
exit 1
fi
@swarawan
Copy link
Author

swarawan commented Sep 14, 2020

How to do:

  1. Put above file to .git/hooks directory
  2. Run sudo chmod +x pre-push to make it executable

Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment