Home | Info | Research | Blog | Repos | Messages | Contact Me

 


Subversion에는 커밋을 하면 커밋 로그와 변경사항을 메일로 보내주는 기능이 있습니다. subversion 안에 있는 mailer.py 스크립트는 일반 메일서버로는 메일이 잘 보내지지만 Gmail SMTP는 사용이 잘 되지 않습니다. mailer.py를 약간 수정하면 Gmail SMTP로도 커밋 로그 메일을 잘 보낼 수 있습니다. (리눅스의 경우 자체 sendmail을 통해 보내는 것은 수정 없이도 가능합니다.)

mailer.py 스크립트는 Subversion 소스 안에 tools/hook-scripts/mailer에 있습니다.

일단 이 스크립트를 사용하려면 저장소의 hooks 디렉토리안에 post-commit.tmpl 파일을 post-commit으로 이름을 바꿉니다. (Windows의 경우 post-commit.bat으로) 그리고 post-commit 파일의 맨 아래에 다음을 추가합니다.

Linux, BSD 등.
/repos/mailer.py commit "$REPOS" "$REV" /repos/mailer.conf

Windows
C:\repos\mailer.py commit %REPOS% %REV% C:\repos\mailer.conf


그리고 mailer.conf.example를 mailer.conf로 이름을 바꾸고 내용 Gmail에 맞게 설정을 합니다.

# This option specifies the hostname for delivery via SMTP.
smtp_hostname = smtp.gmail.com:587

# Username and password for SMTP servers requiring authorisation.
smtp_username = example@gmail.com
smtp_password = (이메일 암호)

다른 설정은 자신의 환경에 맞게 설정합니다.

mailer.py의 SMTPOutput 클래스 finish 함수를 아래와 같이 수정합니다.
def finish(self):
  server = smtplib.SMTP(self.cfg.general.smtp_hostname)
  if self.cfg.is_set('general.smtp_username'):
    server.ehlo()         # 추가된 부분
    server.starttls()     # 추가된 부분
    server.ehlo()         # 추가된 부분
    server.login(self.cfg.general.smtp_username,
                 self.cfg.general.smtp_password)
  server.sendmail(self.from_addr, self.to_addrs, self.buffer.getvalue())
  server.close()          # server.quit()를 server.close()로 수정.

이렇게 하면 Gmail SMTP 서버를 통해서 커밋 로그 메일을 보낼 수 있습니다.
Gmail은 TLS 인증을 사용하기 때문에 starttls()함수를 호출해 줘야 로그인이 됩니다.

트랙백 주소 :: http://www.pyrasis.com/blog/trackback/30

  1. Subject: Commit Mail for SubVersion

    Tracked from 미친고양이의 세상 2007/07/09 18:43  삭제

    아. 정말 몇일 훌떡 날린것을 생각하면 기가 막히다. 폴란드법인에서 가라 샌드메일(http://glob.com.au/sendmail/)로 회사에 Commit Email서비스가 된다고 해서. 이것을 이용해 볼려고 몇일을 투자했는..

댓글을 달아 주세요

  1. BlogIcon ultracat 2007/07/09 18:44  댓글주소  수정/삭제  댓글쓰기

    sendmail때문에 실의에 빠져있다가 이글을 발견하고 쉽게 해결했습니다. 정말 감사해요.. ^^...
    리눅스 서버한대면 쉽게 해결될터인데...
    회사에서 서버한대 받기가 힘들어서 ㅠ.ㅠ.