特拉维斯+ Appveyor

Travis + Appveyor

我正在使用 travis 阶段,并希望以某种方式将 appveyor 构建结果作为部署的先决条件。

是否有可用的集成或脚本来执行此操作? python 最理想。

这样的事情可以帮助启动 AppVeyor 构建并等待结果。抱歉,我更习惯使用 PowerShell,但它应该很容易翻译成 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
}