diff --git a/tools/travis.ps1 b/tools/travis.ps1 index 2b3281e68c..bc43852173 100644 --- a/tools/travis.ps1 +++ b/tools/travis.ps1 @@ -4,6 +4,43 @@ param( Import-Module $PSScriptRoot/../build.psm1 -Force Import-Module $PSScriptRoot/packaging -Force + +function Send-DailyWebHook +{ + param ( + [Parameter(Mandatory=$true,Position=0)][ValidateSet("Pass","Fail")]$result + ) + + # Only send web hook if the environment variable is present + # Varible should be set in Travis-CI.org settings + if ($env:WebHookUrl) + { + $webhook = $env:WebHookUrl + + $Body = @{ + 'text'= @" +Build Result: $result
+OS Type: $($PSVersionTable.OS)
+Build $env:TRAVIS_BUILD_NUMBER
+Job $env:TRAVIS_JOB_NUMBER +"@ + } + + $params = @{ + Headers = @{'accept'='application/json'} + Body = $Body | convertto-json + Method = 'Post' + URI = $webhook + } + + Invoke-RestMethod @params + } + else + { + log "Skipping DailyWebHook. WebHookUrl environment variable not present." + } +} + # This function retrieves the appropriate svg to be used when presenting # the daily test run badge # the location in azure is public readonly @@ -236,6 +273,12 @@ else catch { Write-Warning "Could not update status badge: $_" } + try { + Send-DailyWebHook -result $result + } + catch { + Write-Warning "Could not send webhook: $_" + } } }