Created
August 28, 2018 16:40
-
-
Save IlyaFinkelshteyn/fb08ac0349c9e18bf67619691fbeb5d4 to your computer and use it in GitHub Desktop.
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
$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" | |
} | |
# get variables collection from server | |
$s = Invoke-RestMethod -Uri $API_URL -Headers $headers -Method Get | |
$rights = (($s.settings.securityDescriptor.roleAces | ? {$_.name -eq $env:ROLE_NAME}).accessRights | ? {$_.name -eq "View"}) | |
if ($rights.allowed -ne $null) {$rights.allowed = $true} else {$rights | Add-Member "allowed" $true} | |
Invoke-RestMethod -Uri 'https://ci.appveyor.com/api/projects' -Headers $headers -Body ($s.settings | ConvertTo-Json -Depth 10) -Method Put |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment