Created
January 5, 2019 04:13
-
-
Save IlyaFinkelshteyn/5547626cb8a7c86a0c7ff9023dec9935 to your computer and use it in GitHub Desktop.
Howto store and update environment setting in JSON to track changes.
This file contains 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 | |
# save to JSON | |
$source | ConvertTo-Json -Depth 10 | Set-Content .\$sourceEnvironmentName.json | |
# store $sourceEnvironmentName.json in repo | |
# edit $sourceEnvironmentName.json if needed | |
# update environment from file | |
$source = $source = Get-Content .\$sourceEnvironmentName.json | ConvertFrom-Json | |
Invoke-RestMethod -Uri 'https://ci.appveyor.com/api/environments' -Headers $headers -Body ($source.environment | ConvertTo-Json -Depth 10) -Method Put |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment