Last active
December 22, 2020 12:43
-
-
Save IlyaFinkelshteyn/27cd01f71ec27d8f1f09cf2ddd228bd6 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
$token = '<API_TOKEN>' | |
$sourceEnvironmentName = '<SOURCE_ENVIRONMENT_NAME>' | |
$headers = @{ | |
"Authorization" = "Bearer $token" | |
"Content-type" = "application/json" | |
} | |
# get source environment ID | |
$sourceEnvironmentId = ((Invoke-RestMethod -Uri "https://ci.appveyor.com/api/environments" -Headers $headers -Method Get) | where {$_.name -eq $sourceEnvironmentName}).deploymentEnvironmentId | |
# get source environment properies | |
$source = Invoke-RestMethod -Uri "https://ci.appveyor.com/api/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 'https://ci.appveyor.com/api/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
@PVXDevOps Thanks a lot, updated!