OS/LINUX

[SVN] Commit 메일 보내기

donghunl 2011. 6. 29. 08:36
반응형
Subversion 이용시 user가 commit을 했을때 이메일 보내기위한 설정

1. 메일 Script생성
[root@test ~]# cd /home/svn/project
[root@test project]# mkdir scripts
[root@test project]# cd scripts
[root@test scripts]# vi svn_email_commit.sh

 #!/bin/bash
REPOS=$1
REV=$2
SENDTO=$3
SENDFROM=보내는 사람주소

LIMITDIFF=200
CHANGELOG=`svnlook log -r $REV $REPOS`
AUTHOR=`svnlook author -r $REV $REPOS`
CHANGED=`svnlook changed -r $REV $REPOS`
DIFF=`svnlook diff -r $REV $REPOS | head --lines=$LIMITDIFF`
DATE=`date`
TMPFILE=/tmp/svn$REV-$RANDOM.message

SUBJECT="SVNCommit ($AUTHOR) $REPOS [$REV]"
echo "-------------------- SVN Commit Notification --------------------
Repository: $REPOS
Revision:   $REV
Author:     $AUTHOR
Date:       $DATE

-----------------------------------------------------------------
Log Message:
-----------------------------------------------------------------
$CHANGELOG

-----------------------------------------------------------------
Changes:
-----------------------------------------------------------------
$CHANGED

-----------------------------------------------------------------
Diff: (only first $LIMITDIFF lines shown)
-----------------------------------------------------------------
$DIFF
" > $TMPFILE

# Send email
cat $TMPFILE | mail -s "$SUBJECT" "$SENDTO" -- -f "$SENDFROM"

# Cleanup
rm $TMPFILE


2. shell script 실행권한 설정
[root@test scripts]# chmod +x svn_email_commit.sh

3. hookup 파일 설정
[root@test scripts]# cd ..
[root@test project]# cd hooks
[root@test hooks]# vi post-commit

#!/bin/sh
REPOS="$1"
REV="$2"
SENDTO="받을사람1, 받을사람2"

# Send it to these people, calling the script we created above
/home/svn/project/scripts/svn_email_commit.sh "$REPOS" "$REV" "$SENDTO"


4. hookup 파일 실행권한 설정
[root@test ~]# chmod +x post-commit

5. commit시 발송되는 이메일 내용

-------------------- SVN Commit Notification --------------------
Repository: /home/svn/project
Revision:   26
Author:     user
Date:       Tue Jun 28 19:08:58 EDT 2011

-----------------------------------------------------------------
Log Message:
-----------------------------------------------------------------
write log here

-----------------------------------------------------------------
Changes:
-----------------------------------------------------------------
A   documents/test.txt

-----------------------------------------------------------------
Diff: (only first 200 lines shown)
-----------------------------------------------------------------
Added: documents/test.txt
===================================================================



반응형