Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
appveyor multiple env deployments
Param(
[string]$environmentName1,
[string]$environmentName2,
[string]$buildVersion
)
$accountName = <your-account-name>
$projectSlug = <your-project-slug>
$token = $env:API_TOKEN #This should be added as a secure variable. Other variables used in script already exist
$headers = @{
"Authorization" = "Bearer $token"
"Content-type" = "application/json"
}
$body1 = @{
environmentName=$environmentName1
buildVersion=$buildVersion
accountName=$accountName
projectSlug=$projectSlug
}
$body1 = $body1 | ConvertTo-Json
$deploymentId = (Invoke-RestMethod -Uri 'https://ci.appveyor.com/api/deployments' -Headers $headers -Body $body1 -Method POST).deploymentId
[bool]$deploymentFinished = $false
[int]$retryCount = 0;
while (!$deploymentFinished)
{
if ($retryCount -gt 10)
{
throw "Reached maximum number of retries while waiting for deployment to complete"
}
$deploymentStatus = (Invoke-RestMethod -Uri "https://ci.appveyor.com/api/deployments/$deploymentId" -Headers $headers -Method Get).deployment.status
$deploymentFinished = $deploymentStatus -eq "success"
Write-Host "Current deployment status: $deploymentStatus"
Write-Host "Sleeping for 10 seconds before next check if deployment finished..."
Start-sleep 10
$retryCount++
}
Write-host "1st Deployment completed" -ForegroundColor Green
$body2 = @{
environmentName=$environment2
buildVersion=$buildVersion
accountName=$accountName
projectSlug=$projectSlug
}
$body2 = $body2 | ConvertTo-Json
$deploymentId = (Invoke-RestMethod -Uri 'https://ci.appveyor.com/api/deployments' -Headers $headers -Body $body2 -Method POST).deploymentId
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.