#!/bin/bash
echo "cd $JENKINS_HOME/jobs/$JOB_BASE_NAME/builds/${BUILD_NUMBER}"
cd $JENKINS_HOME/jobs/$JOB_BASE_NAME/builds/${BUILD_NUMBER}
echo ---

function grep_key_word()
{
	grep -B $2 "$1" log
	if [ $? = 0 ];then
		echo ---
		exit -1
	fi
}

grep_key_word "No space left on device" 1
grep_key_word "Got error: [0-9]\{4\}:" 1
grep_key_word "ERROR [0-9]\{4\} " 1
grep_key_word "show tables failed" 3
grep_key_word "EXEC_SQL_FAIELD Error [0-9]\{4\}" 1

# grep -B 1 "No space left on device" log
# if [ $? = 0 ];then
# 	echo ---
# 	exit -1
# fi

# grep -B 1 "Got error: [0-9]\{4\}:" log
# if [ $? = 0 ];then
# 	echo ---
# 	exit -1
# fi

# grep -B 1 "ERROR [0-9]\{4\} " log
# if [ $? = 0 ];then
# 	echo ---
# 	exit -1
# fi

# grep -B 3 "show tables failed" log
# if [ $? = 0 ];then
# 	echo ---
# 	exit -1
# fi

# grep -B 1 "EXEC_SQL_FAIELD Error 1813" log
# if [ $? = 0 ];then
# 	echo ---
# 	exit -1
# fi
echo "post_build_script_sync_db finish~"
