post-commit devops

[root@jettodevops-prod-30 ~]# cat post-commit 
#!/usr/bin/env bash
SVNBASE="svn://172.16.10.30/"
ORGID="1a"
LOGDIR="/tem"
APIURL="http://172.16.10.35:8771/code/codeReview/addCodeReview"
REPOS="$1"
REV="$2"
REPO=${REPOS##*/}
if [ ! -d  $LOGDIR/ ];then
mkdir -p $LOGDIR/
fi
LOGFILE="${LOGDIR}/${REPO}_${REV}.log"
export LANG=zh_CN.UTF-8
#下面的"/usr/bin/svnlook",是需用户手动输入svnlook的路径
USER=$(/usr/bin/svnlook author -r "$REV" "$REPOS")
DATEALL=$(/usr/bin/svnlook date -r "$REV" "$REPOS")
LOGORIGIN=$(/usr/bin/svnlook log -r "$REV" "$REPOS")
encodelist=`echo ${LOGORIGIN} | tr -d '\n' | xxd -plain | sed 's/\(..\)/%\1/g'`
LOG=''
for i in $encodelist;do LOG=$LOG$i;done
DATE=${DATEALL:0:10}"T"${DATEALL:11:8}".08Z"
echo "curl -s -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Bearer' -d '{\"branchName\": \"$BRANCH\",\"commitLog\": \"$LOG\",\"operTime\": \"$DATE\",\"operUser\": \"$USER\",\"orgId\": \"$ORGID\",\"repositoryUrl\": \"$SVNBASE$REPO\",\"reviewStatus\": 0,\"systemId\": \"$SYSTEMID\",\"systemName\": \"$SYSTEMNAME\",\"type\": \"Subversion\",\"versionNum\": \"$REV\"}' $APIURL" >$LOGFILE 2>&1
echo $LANG  >>$LOGFILE 2>&1
status=`/usr/bin/curl -s -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Bearer' -d '{"branchName": "'$BRANCH'","commitLog": "'$LOG'","operTime": "'$DATE'","operUser": "'$USER'","orgId": "'$ORGID'","repositoryUrl": "'$SVNBASE$REPO'","reviewStatus": 0,"systemId": "'$SYSTEMID'","systemName": "'$SYSTEMNAME'","type": "Subversion","versionNum": "'$REV'"}' ${APIURL}`
echo "$status" >>$LOGFILE 2>&1

你可能感兴趣的:(linux)