-
-
Save eydelrivero/69ede85b15cd02a0e9183628313649c4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$apiBaseUrl = 'https://ci.appveyor.com/api/account/<ACCOUNT_NAME>' | |
$token = '<API_TOKEN>' | |
$sourceEnvironmentName = '<SOURCE_ENVIRONMENT_NAME>' | |
Write-Host "$apiBaseUrl/environments" | |
$headers = @{ | |
"Authorization" = "Bearer $token" | |
"Content-type" = "application/json" | |
} | |
# get source environment ID | |
$sourceEnvironmentId = ((Invoke-RestMethod -Uri "$apiBaseUrl/environments" -Headers $headers -Method Get) | where {$_.name -eq $sourceEnvironmentName}).deploymentEnvironmentId | |
# get source environment properies | |
$source = Invoke-RestMethod -Uri "$apiBaseUrl/environments/$sourceEnvironmentId/settings" -Headers $headers -Method Get | |
# optionally update name | |
$source.environment.name = ($source.environment.name + " - NEW") | |
# create new environment with properies from the source | |
Invoke-RestMethod -Uri "$apiBaseUrl/environments" -Headers $headers -Body ($source.environment | ConvertTo-Json -Depth 10) -Method Post |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment