Skip to content

Instantly share code, notes, and snippets.

@bayological
Created February 5, 2020 17:28
Show Gist options
  • Save bayological/0e3f7d4f8d3626a6b6a7b426f31aace6 to your computer and use it in GitHub Desktop.
Save bayological/0e3f7d4f8d3626a6b6a7b426f31aace6 to your computer and use it in GitHub Desktop.
$url = "$($env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI)$env:SYSTEM_TEAMPROJECTID/_apis/Release/definitions/$($env:RELEASE_DEFINITIONID)?api-version=5.0"
#Get definition
$pipeline = Invoke-RestMethod -Uri $url -Headers @{
Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN"
}
#Update variable
$pipeline.variables.MyVariableName.value = "New value"
#Update the modified object to JSON
$json = @($pipeline) | ConvertTo-Json -Depth 99
#Update the definition via api
$updatedef = Invoke-RestMethod -Uri $url -Method Put -Body $json -ContentType "application/json" -Headers @{Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment