Skip to content

Instantly share code, notes, and snippets.

@wattengard
Created October 2, 2012 06:21
Show Gist options
  • Save wattengard/3816744 to your computer and use it in GitHub Desktop.
Save wattengard/3816744 to your computer and use it in GitHub Desktop.
Powershell script to mail changelog for recent day
# Send SVN log to mail recipients
# Get SVN-formatted date for yesterday
$yesterday = $yesterday = ((Get-Date) - ([System.TimeSpan]::FromDays(1))).ToString("yyyy-MM-dd")
# Our SVN-command. This is failing/working on two different systems. It's complaining about the DATE-format in the revision parameter
# You should also probably add the --username and --password parameters
$svncommand = "svn log -r '{$yesterday}:HEAD' svn://my.svn.server/project/trunk"
# Hack to get correct output encoding
$OutputEncoding = [Console]::OutputEncoding
$output = iex $svncommand | Out-String
if ($output)
{
$smtpServer = "mail.example.com"
$msg = New-Object Net.Mail.MailMessage
$smtp = New-Object Net.Mail.SmtpClient($smtpServer)
$msg.From = "svn-no-reply@example.com"
$msg.To.Add("me@example.com")
$msg.To.Add("other@example.com")
$msg.Subject = "Subversion commitlog for $yesterday"
$msg.Body = $output
$smtp.Send($msg)
} else {
Write-Output "Fail"
Write-Output $svncommand
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment