Skip to content

Instantly share code, notes, and snippets.

@tandv592082
Created May 30, 2023 10:16
Show Gist options
  • Select an option

  • Save tandv592082/0dd76f9a0aebf890627e06ca54abca17 to your computer and use it in GitHub Desktop.

Select an option

Save tandv592082/0dd76f9a0aebf890627e06ca54abca17 to your computer and use it in GitHub Desktop.
pre commit hook
#!/bin/sh
REPOS="$1"
TXN="$2"
MAVEN_HOME="/opt/apache-maven-3.6.3"
# Change to your project's directory
PROJECT_DIR="/home/tandv/Desktop/convention/demo"
# Change to the project directory
cd "$PROJECT_DIR" || exit 1
# Run Maven build and tests
"$MAVEN_HOME/bin/mvn" clean verify
# Check the build result
if [ $? -ne 0 ]; then
echo "Maven build or tests failed. Commit rejected."
exit 1
fi
# All checks passed, allow the commit
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment