Make sure web hook gets called (#5249)

if something goes wrong during the build, we might exit and not update the badge or fire the webhook.

Enable the after_success and after_failure stages of the travis-ci build so we can have a better chance of getting these done.
This commit is contained in:
Travis Plunk
2017-10-27 11:35:40 -07:00
committed by GitHub
parent 4df703616a
commit ce03a6c2be
2 changed files with 48 additions and 27 deletions
+7 -1
View File
@@ -35,7 +35,7 @@ install:
npm install -g markdown-spellcheck@0.11.0;
fi
- ulimit -n 4096
- pwsh -File tools/travis.ps1 -Bootstrap
- pwsh -File tools/travis.ps1 -Stage Bootstrap
script:
- pwsh -File tools/travis.ps1
@@ -43,3 +43,9 @@ script:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
mdspell '**/*.md' '!powershell/**/*.md' --ignore-numbers --ignore-acronyms --report;
fi
after_failure:
- pwsh -File tools/travis.ps1 -Stage Failure
after_success:
- pwsh -File tools/travis.ps1 -Stage Success
+41 -26
View File
@@ -1,6 +1,8 @@
param(
[switch]$Bootstrap
[ValidateSet('Bootstrap','Build','Failure','Success')]
[String]$Stage = 'Build'
)
Import-Module $PSScriptRoot/../build.psm1 -Force
Import-Module $PSScriptRoot/packaging -Force
@@ -158,14 +160,14 @@ $isDailyBuild = $env:TRAVIS_EVENT_TYPE -eq 'cron' -or $env:TRAVIS_EVENT_TYPE -eq
$cronBuild = $env:TRAVIS_EVENT_TYPE -eq 'cron'
$isFullBuild = $isDailyBuild -or $hasFeatureTag
if($Bootstrap.IsPresent)
if($Stage -eq 'Bootstrap')
{
Write-Host -Foreground Green "Executing travis.ps1 -BootStrap `$isPR='$isPr' - $commitMessage"
# Make sure we have all the tags
Sync-PSTags -AddRemoteIfMissing
Start-PSBootstrap -Package:(-not $isPr)
}
else
elseif($Stage -eq 'Build')
{
$BaseVersion = (Get-PSVersion -OmitCommitId) + '-'
Write-Host -Foreground Green "Executing travis.ps1 `$isPR='$isPr' `$isFullBuild='$isFullBuild' - $commitMessage"
@@ -269,29 +271,6 @@ else
Start-NativeExecution -sb {dotnet nuget push $package --api-key $env:NUGET_KEY --source "$env:NUGET_URL/api/v2/package"} -IgnoreExitcode
}
}
# update the badge if you've done a cron build, these are not fatal issues
if ( $cronBuild ) {
try {
$svgData = Get-DailyBadge -result $result
if ( ! $svgData ) {
write-warning "Could not retrieve $result badge"
}
else {
log "Setting status badge to '$result'"
Set-DailyBuildBadge -content $svgData
}
}
catch {
Write-Warning "Could not update status badge: $_"
}
try {
Send-DailyWebHook -result $result
}
catch {
Write-Warning "Could not send webhook: $_"
}
}
}
# if the tests did not pass, throw the reason why
@@ -299,3 +278,39 @@ else
Throw $resultError
}
}
elseif($Stage -in 'Failure', 'Success')
{
$result = 'PASS'
if($Stage -eq 'Failure')
{
$result = 'FAIL'
}
if ($cronBuild) {
# update the badge if you've done a cron build, these are not fatal issues
try {
$svgData = Get-DailyBadge -result $result
if ( ! $svgData ) {
write-warning "Could not retrieve $result badge"
}
else {
log "Setting status badge to '$result'"
Set-DailyBuildBadge -content $svgData
}
}
catch {
Write-Warning "Could not update status badge: $_"
}
try {
Send-DailyWebHook -result $result
}
catch {
Write-Warning "Could not send webhook: $_"
}
}
else {
log 'We only send bagde or webhook update for Cron builds'
}
}