private/jira/Send-ReleaseNotes.ps1
#TODO function Send-ReleaseNotes( [string[]]$to, [string[]]$cc, [string]$product, [string]$version, [string]$build, [ValidateSet('PRE-ALPHA','ALPHA','BETA', 'FINAL')] [string]$stage, [ValidateSet('TXT','HTML')] [string]$outputType = 'HTML', [ValidateSet('AS_IS', 'CLOSED', 'Blocked')] [string]$publicStatus = 'Blocked', [string]$jiraUsername, [string]$jiraPassword, [string]$smtpFrom, [string]$smtpUsername, [string]$smtpPassword) { if ($jiraUsername -ne '') { $m_jiraUsername = $jiraUsername } if ($jiraPassword -ne '') { $m_jiraPassword = $jiraPassword } if ($smtpFrom -ne '') { $m_smtpFrom = $smtpFrom } if ($smtpUsername -ne '') { $m_smtpUsername = $smtpUsername } if ($smtpPassword -ne '') { $m_smtpPassword = $smtpPassword } $_subject = "[{product}] {project} {version}{build} has been released as {stage}" if ($build -ne '') { $build = ".$build" } $_project = Get-JiraProjectByKey $product if ($_project -ne ''){ $_body = Get-JiraNotes -product $product -version $version -build $build -outputType ` $outputType -notes release -stage $stage -publicStatus $publicStatus ` -userName $m_jiraUsername -password $m_jiraPassword $_subject = $_subject.Replace('{product}', $product).Replace('{project}', $_project).Replace('{version}', ` $version).Replace('{build}', "$build").Replace('{stage}', $stage) $_secPasswd = ConvertTo-SecureString $m_smtpPassword -AsPlainText -Force $_credential = New-Object System.Management.Automation.PSCredential ($m_smtpUsername, $_secPasswd) if ($to -ne 'SCREEN'){ if ($outputType -eq 'HTML'){ if ([string]::IsNullOrEmpty($cc)) { Send-MailMessage -From $m_smtpFrom -to $to -Subject $_subject -Body $_body -BodyAsHtml ` -SmtpServer $m_smtpServer -port $m_smtpPort -UseSsl -Credential $_credential } else { Send-MailMessage -From $m_smtpFrom -to $to -Cc $cc -Subject $_subject -Body $_body -BodyAsHtml ` -SmtpServer $m_smtpServer -port $m_smtpPort -UseSsl -Credential $_credential } } else{ if ([string]::IsNullOrEmpty($cc)) { Send-MailMessage -From $m_smtpFrom -to $to -Subject $_subject -Body $_body ` -SmtpServer $m_smtpServer -port $m_smtpPort -UseSsl -Credential $_credential } else { Send-MailMessage -From $m_smtpFrom -to $to -Cc $cc -Subject $_subject -Body $_body ` -SmtpServer $m_smtpServer -port $m_smtpPort -UseSsl -Credential $_credential } } } else{ Write-Host "Subject: $_subject" Write-Host "Body:`n$_body" } } } |