Search code examples
pythontravis-ciappveyor

Travis + Appveyor


I am using travis stages and would like to somehow include the appveyor build result as a precondition for deployment.

Is there any integration or script already available that does this? python would be ideal.


Solution

  • Something like this can help to start AppVeyor build and wait for result. Sorry I am more comfortable with PowerShell but it should be easy to translate to Python.

    $token="<Your_api_token>"
    $accountName="<Your_account>"
    $projectSlug="<Your_project_slug>"
    $branch="<Your_branch>"
    $commitId="<Your_commit_id>"
    
    $headers = @{
      "Authorization" = "Bearer $token"
      "Content-type" = "application/json"
    }
    
    $body = @{
        accountName=$accountName
        projectSlug=$projectSlug
        branch=$branch
        commitId=$commitId
    }
    
    $body = $body | ConvertTo-Json
    
    $newBuild = Invoke-RestMethod -Uri 'https://ci.appveyor.com/api/builds' -Headers $headers  -Body $body -Method POST
    
    $success = $false;
    while(!$success) {
    $status = (Invoke-RestMethod -Uri "https://ci.appveyor.com/api/projects/$accountName/$projectSlug/build/$($newBuild.version)" -Headers $headers  -Method GET).build.status
    write-host "Status: $status"
    $success = $status -eq "success"
    if (($status -eq "failed") -or ($status -eq "cancelled")) {throw}
    sleep 2
    }