Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
# install https://github.com/travis-ci/travis.rb#installation
# get API token according https://developer.travis-ci.com/authentication
$env:TRAVIS_API_TOKEN = "<replace>" # must be secure variable set in Environment tab or YAML section
$env:TimeOutMins = <replace> # how long to wait for Travis build to complete (set in Environment tab or YAML section)
$headers = @{
"Authorization" = "token $env:TRAVIS_API_TOKEN"
"Travis-API-Version" = "3"
}
[datetime]$stop = ([datetime]::Now).AddMinutes($env:TimeOutMins)
[bool]$success = $false
while(!$success -and ([datetime]::Now) -lt $stop) {
$builds = Invoke-RestMethod -Uri "https://api.travis-ci.org/builds?limit=10" -Headers $headers -Method Get
$currentBuild = $builds.builds | ? {$_.commit.sha -eq $env:APPVEYOR_REPO_COMMIT}
$success = $currentBuild.state -eq "passed"
if (!$success) {Start-sleep 5}
}
if (!$currentBuild) {throw "Could not get information about Travis build with sha $env:APPVEYOR_REPO_COMMIT"}
if (!$success) {throw "Travis build did not finished in $env:TimeOutMins minutes"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment