이 스크립트 중 나와 공유 할 수 있습니까?누구나 코드 커밋시 전자 메일을 보낼 커밋 알림 훅 스크립트가 있습니까?
답변
기본값은 commit-email.pl이며 Subversion을 설치할 때 포함됩니다. 그러나 here 루비에서 하나 : 당신의 SVN 저장소의 후크 디렉토리에서
#!/usr/bin/ruby -w
# A Subversion post-commit hook. Edit the configurable stuff below, and
# copy into your repository's hooks/ directory as "post-commit". Don't
# forget to "chmod a+x post-commit".
# ------------------------------------------------------------------------
# You *will* need to change these.
address="[email protected]_DOMAIN.com"
sendmail="/usr/sbin/sendmail"
svnlook="/usr/bin/svnlook"
# ------------------------------------------------------------------------
require 'cgi'
# Subversion's commit-email.pl suggests that svnlook might create files.
Dir.chdir("/tmp")
# What revision in what repository?
repo = ARGV.shift()
rev = ARGV.shift()
# Get the overview information.
info=`#{svnlook} info #{repo} -r #{rev}`
info_lines=info.split("\n")
author=info_lines.shift
date=info_lines.shift
info_lines.shift
comment=info_lines
# Output the overview.
body = "<p><b>#{author}</b> #{date}</p>"
body << "<p>"
comment.each { |line| body << "#{CGI.escapeHTML(line)}<br/>\n" }
body << "</p>"
body << "<hr noshade>"
# Get and output the patch.
changes=`#{svnlook} diff #{repo} -r #{rev}`
body << "<pre>"
changes.each do |top_line|
top_line.split("\n").each do |line|
color = case
when line =~ /^Modified:/|| line =~ /^=+$/ || line =~ /^@@ /: "gray"
when line =~ /^-/: "red"
when line =~ /^\+/: "blue"
else "black"
end
body << %Q{<font style="color:#{color}">#{CGI.escapeHTML(line)}</font><br/>\n}
end
end
body << "</pre>"
# Write the header.
header = ""
header << "To: #{address}\n"
header << "From: #{address}\n"
header << "Subject: [SVN] #{repo} revision #{rev}\n"
header << "Reply-to: #{address}\n"
header << "MIME-Version: 1.0\n"
header << "Content-Type: text/html; charset=UTF-8\n"
header << "Content-Transfer-Encoding: 8bit\n"
header << "\n"
# Send the mail.
begin
fd = open("|#{sendmail} #{address}", "w")
fd.print(header)
fd.print(body)
rescue
exit(1)
end
fd.close
# We're done.
exit(0)
, 당신은 포스트 commit.tmpl 스크립트를 찾을 수 있습니다. 그것을 "post-commit"이라는 이름으로 복사하고 적합하도록 편집하십시오. 보통 Subversion과 함께 제공되는 commit-email.pl 스크립트를 실행합니다. 또한 원하는 방식으로 편집 할 수 있어야합니다.
웬일인지, 루비 스크립트와 기본 훅 스크립트가 나에게 적합하지 않았다. 이것은 우리의 메일 서버와 몇 가지 이상한 점 때문일 수도 있지만 어쨌든 여기에서 중요한 부분을 포함합니다 :
#!/bin/sh
REPOS="$1"
REV="$2"
svnnotify --repos-path "$REPOS" --revision "$REV" --with-diff --to [email protected] --smtp mailserver.domain --from [email protected] -VVVVVVVVV -P "[repository_name]"
-VVVVVVV 부분을 표시 매우 자세한 메시지를 스크립트 외부에서 명령을 테스트하려는 경우. 실제 스크립트에서 제거해야합니다.
물론이 기능을 사용하려면 svnnotify를 설치해야합니다. perl과 함께 제공되는 cpan을 먼저 설치하면됩니다. 그런 다음 cpan을 시작하고 SVN :: Notify 라이브러리를 설치해야합니다.
$ cpan
cpan> install SVN::Notify
'$'및 'cpan>'부분은 단지 프롬프트이므로 입력 할 필요가 없습니다.
이 솔루션은 제가 언급 한 메일 서버의 문제를 해결하는 데 도움이되는 자세한 오류 메시지를 제공했기 때문에 훨씬 매력적이었습니다. 또한 여러 저장소가 있으므로 전체 프로그램/스크립트를 각 디렉토리에 복사하는 것이 불필요합니다. 귀하의 마일리지가 다를 수 있습니다.
맨 위에있는 코드 블록의 텍스트는 "post-commit"이라는 텍스트 파일에 있어야합니다. 이 파일은/path/to/svn/repos/repository_name/hooks에 있고 실행 가능으로 표시되어야합니다.
#!/bin/ksh
#
# This is a custom post-commit for sending email
# when an svn repo is changed.
#
rcpts="[email protected], [email protected]"
repodir=$1
revision=$2
author=`/usr/bin/svnlook author -r $revision $repodir`
date=`/usr/bin/svnlook date -r $revision $repodir`
log=`/usr/bin/svnlook log -r $revision $repodir`
info=`/usr/bin/svnlook changed -r $revision $repodir`
repo=${repodir##*/}
subject="$repo svn updated by $author"
url="https://myserver.bar.edu/svn/$repo"
/usr/bin/mail -s "$subject" "$rcpts"<<EOM
repository: $url
date: $date
username: $author
revision: $revision
comment: $log
$info
EOM
받은 후 인터넷 :: SMTP_auth`를 설치> 나는 또한 한이
/usr/bin/svnnotify --revision "$REV" --repos-path "$REPOS" \ --subject-cx --subject-prefix "[Project:commit] " --max-sub-length 128 \ --with-diff --handler Alternative --alt HTML::ColorDiff \ --to '[email protected]' --from '[email protected]' --set-sender
- 1. 'git'에 대한 JIRA 코드 검증 커밋 훅
- 2. 전자 메일을 보낼 때의 문제
- 3. 전자 메일을 어떻게 trac에 보낼 수 있습니까?
- 4. Uploadify가 완료되면 전자 메일을 보낼 수 있습니까?
- 5. 어떻게 전자 메일을 C로 보낼 수 있습니까?
- 6. 단일 페이지로 전자 메일을 보낼 수 있습니까
- 7. 전자 메일을 보낼 때 스레딩
- 8. 전자 메일을 보낼 일괄 스크립트
- 9. blat을 사용하여 커밋 버전의 전자 메일을 전자 메일로 보낼 수 있습니까?
- 10. SVN - 코드 형식을 검사하기위한 사전 커밋 훅
- 11. HTML 전자 메일을 보낼 수 없습니다.
- 12. git에서 커밋 훅 처리하기
- 13. .NET (System.Net.Email) - 전자 메일을 보낼 때의 문제
- 14. 응용 프로그램에서 전자 메일을 보낼 수 없음
- 15. 전자 메일을 보낼 때 문자를 이스케이프 처리해야합니까?
- 16. 전자 메일 알림 서비스
- 17. 누구나 sendmail과 subprocess를 사용하여 메일을 보내는 python 코드 예가 있습니까?
- 18. TFS 전자 메일 알림
- 19. CodeIgniter 전자 메일을 보낼 수 없습니다.
- 20. Outlook에서 전자 메일을 보낼 때 메서드를 호출합니까?
- 21. Git Post 커밋 훅 커밋 번호 얻기
- 22. SMTP를 통해 대량의 전자 메일을 보낼 때의 위험도
- 23. xslt를 사용하여 전자 메일을 xml 데이터로 보낼 수 있습니까?
- 24. git commit 전자 메일을 여러 수신자에게 보낼 수 있습니까?
- 25. 웹 페이지에서 전자 메일을 통해 파일을 보낼 수 있습니까?
- 26. cURL을 사용하여 프록시를 통해 전자 메일을 보낼 수 있습니까?
- 27. VS2010 개발 서버를 사용하여 전자 메일을 보낼 수 있습니까?
- 28. ASP.NET이 아닌 .exe를 통해 전자 메일을 보낼 수 있습니까?
- 29. 포스트 커밋 훅 with Trac
- 30. Subversion : 커밋시 코드 파일에 개정 데이터 추가
가'CPAN을하려고 – philfreo
또한주의 "NET/SMTP_auth.pm가 @INC에서 찾을 수 없습니다" Gmail로 보내기 위해 기본적으로 작동하지 않습니다. http://cpanforum.com/posts/10541와'cpan> install Net :: SMTP :: SSL'을보십시오. – philfreo