-
-
Save polunzh/77cbb66876c965bf3161 to your computer and use it in GitHub Desktop.
Maven pre commit hook
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
#!/bin/bash | |
# 放在 <git_directory>/.git/hooks/pre-commit | |
echo "执行 Maven clean test 检查单元测试是否通过..." | |
# retrieving current working directory | |
CWD=`pwd` | |
MAIN_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
# 返回项目主目录 | |
cd $MAIN_DIR/../../ | |
# 执行 maven clean test | |
mvn clean test | |
if [ $? -ne 0 ]; then | |
echo "[Failed] 单元测试未通过!" | |
# 返回当前工作目录 | |
cd $CWD | |
exit 1 | |
fi | |
# 返回当前工作目录 | |
cd $CWD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment