Functions/Tracing/Write-CdsMessageToSlack.ps1
<#
.SYNOPSIS Push message to slack #> function Write-CdsMessageToSlack { [CmdletBinding()] param ( [Parameter(Mandatory = $false)] [String] $SlackUrl = $env:SLACKURL, [Parameter(Mandatory=$false)] [String] $BotName = "DevOps", [Parameter(Mandatory=$true)] [String] $Message, [Parameter(Mandatory=$false)] [String] $Emoji ) process { if($BotName -eq "DevOps") { $projectName = $env:SYSTEM_TEAMPROJECT; if($env:BUILD_DEFINITIONNAME) { $BotName = "DevOps $projectName : Build $($env:BUILD_DEFINITIONNAME)"; } elseif($env:RELEASE_DEFINITIONNAME) { $BotName = "DevOps $projectName : Release $($env:RELEASE_DEFINITIONNAME)"; } } $BodyTemplate = ConvertTo-Json @{ username = "$BotName" text = "$Message" icon_emoji = "$Emoji" } Invoke-RestMethod -uri $SlackUrl -Method Post -body $BodyTemplate -ContentType 'application/json' | Out-Null; } } Export-ModuleMember -Function Write-CdsMessageToSlack -Alias *; |