private/jira/Send-TechnicalNotes.ps1
#TODO function Send-TechnicalNotes( [string[]]$to, [string[]]$cc, [string]$product, [string]$version, [string]$build, [ValidateSet('PRE-ALPHA','ALPHA','BETA', 'FINAL')] [string]$stage, [ValidateSet('TXT','HTML')] [string]$outputType = 'HTML', [string]$jiraUsername, [string]$jiraPassword, [string]$smtpFrom, [string]$smtpUsername, [string]$smtpPassword, [ValidateSet('DB','CONFIG','DEV', 'ALL')] [string]$changes='ALL'){ 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} technical release notes {changeType}" $_project = Get-JiraProjectByKey $product if ($_project -ne ''){ if ($build -ne '') { $build = ".$build" } $_body = Get-JiraNotes -product $product -version $version -build $build -outputType ` $outputType -notes technical -changes $changes -userName $m_jiraUsername -password $m_jiraPassword $_subject = $_subject.Replace('{product}', $product).Replace('{project}', ` $_project).Replace('{version}', $version).Replace('{build}', ".$build") $_changeType = '' switch ($changes) { 'DB' { $_changeType = '- database changes' } 'CONFIG' { $_changeType = '- configuration changes' } 'DEV' { $_changeType = '- developer notes' } } $_subject = $_subject.Replace('{changeType}', $_changeType) $_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 ` $_smtpServer -port $m_smtpPort -UseSsl -Credential $_credential } else { Send-MailMessage -From $m_smtpFrom -to $to -Cc $cc -Subject $_subject -Body $_body -SmtpServer ` $_smtpServer -port $m_smtpPort -UseSsl -Credential $_credential } } } else{ Write-Host "Subject: $_subject" Write-Host "Body:`n$_body" } } } |