Skip to content

Instantly share code, notes, and snippets.

View IlyaFinkelshteyn's full-sized avatar

Ilya Finkelshteyn IlyaFinkelshteyn

  • Azure App Service
  • Seattle WA
View GitHub Profile
# $env:API_KEY should be defined as a secure variable
$headers = @{
"Authorization" = "$env:API_KEY"
"Content-type" = "application/json"
}
$apiURL = "https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG"
$history = Invoke-RestMethod -Uri "$apiURL/history?recordsNumber=5" -Headers $headers -Method Get
@IlyaFinkelshteyn
IlyaFinkelshteyn / EnvironmentSettingJson.ps1
Created January 5, 2019 04:13
Howto store and update environment setting in JSON to track changes.
$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
$env:API_TOKEN="<replace>" # https://ci.appveyor.com/api-keys
$env:APPVEYOR_ACCOUNT_NAME="<replace>" # from AppVeyor URL (after "project/")
$env:APPVEYOR_PROJECT_SLUG="<replace>" # from AppVeyor URL (after account name)
$env:recordsNumber = 20
$headers = @{
"Authorization" = "Bearer $env:API_TOKEN"
"Content-type" = "application/json"
}
$env:API_URL = "https://ci.appveyor.com/api" # replace for AppVeyor Enterprise
$env:API_TOKEN = "<replace>" # from https://ci.appveyor.com/api-keys
$env:APPVEYOR_ACCOUNT_NAME = "<replace>" # from AppVeyor project URL
$env:APPVEYOR_PROJECT_SLUG_OLD = "<replace>" # from AppVeyor project URL
$env:APPVEYOR_PROJECT_SLUG_NEW = "<replace>" # Desired slug
$headers = @{
"Authorization" = "Bearer $env:API_TOKEN"
"Content-type" = "application/json"
}
$token = '<replace>'
$roles = @("role1", "role2")
$headers = @{
"Authorization" = "Bearer $token"
"Content-type" = "application/json"
}
function UpdateSingleRolePermission ($roleName, $environmentId, $permission) {
$setting = Invoke-RestMethod -Uri "https://ci.appveyor.com/api/environments/$environmentId/settings" -Headers $headers -Method Get
$env:API_TOKEN = "<replace>" # from https://ci.appveyor.com/api-token
$env:APPVEYOR_ACCOUNT_NAME = "<replace>" # from AppVeyor project URL
$env:APPVEYOR_PROJECT_SLUG = "<replace>" # from AppVeyor project URL
$env:ROLE_NAME = "<replace>" # role to update permissions
$API_URL = "https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/settings"
$headers = @{
"Authorization" = "Bearer $env:API_TOKEN"
"Content-type" = "application/json"
$apiUrl = "https://ci.appveyor.com/api" # replace with AppVeyor Enterprise URL if needed
$token = "<your_API_token>" # from https://ci.appveyor.com/api-token" or similar AppVeyor Enterprise URL
$buildEnvironmentId = "your_build_environment_id" # you can get it from build environment URL
$newVmSize = "<VM_Size_not_listed_in_AppVeyor_UI>" # https://docs.microsoft.com/en-us/azure/virtual-machines/windows/sizes
$headers = @{
"Authorization" = "Bearer $token"
"Content-type" = "application/json"
}
$token="<Your_api_token>"
$accountName="<Your_account>"
$projectSlug="<Your_project_slug>"
$toFind = @("foo", "bar")
$headers = @{
"Authorization" = "Bearer $token"
"Content-type" = "application/json"
}
#WARNING: this may work unpredictable with parallel build of the same project (parallel jobs in matrix are fine)
#Note $separator variable. If "-" can be used earlier in build version, replace it to something unique
version: 0.1.{build}
environment:
API_TOKEN:
secure: SlDEDtAKuvsy+VErEuc/4DxdhPeKu2WRqvYzEh/fiH4=
for:
$API_TOKEN = "<replace>" # from https://ci.appveyor.com/api-token
$APPVEYOR_ACCOUNT_NAME = "<replace>" # from AppVeyor project URL
$APPVEYOR_PROJECT_SLUG = "<replace>" # from AppVeyor project URL
$VAR_NAME = "<replace>" # name of variable to update
$VAR_NEW_VALUE = "<replace>" # new variable value
$API_URL = "https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/settings/environment-variables"
$ENCRYPT_URL = "https://ci.appveyor.com/api/account/encrypt"
$headers = @{