'Issue setting Release pipeline property via REST APIs in Azure DevOps
I am trying to set a property in the Integrations section of a Release pipeline through REST APIs. In the process, I find that a specific property cannot be set until it has been enabled via UI at least once before. The specific property is "BoardsEnvironmentType" and i see this error while trying to set it in the json object,
"The property '$value' cannot be found on this object. Verify that the property exists and can be set."
To reiterate, the same code works if I set the property through UI at least once before, here is the image of the property I am referring to,
Here is my code snippet,
$releaseDefinitions = Invoke-RestMethod -Uri "https://vsrm.dev.azure.com/$organisation/$teamProject/_apis/release/definitions?path=\$Path&api-version=6.1-preview.4" -Method Get -Headers $headers
$releaseDefIds = $releaseDefinitions.value.id
foreach ($id in $releaseDefIds)
{
Write-Host "$id"
$releaseDefUrl = "https://vsrm.dev.azure.com/$organisation/$teamProject/_apis/release/definitions/"+"$id"+"?api-version=6.1-preview.4"
$releaseDefinitionDetail = Invoke-RestMethod -Uri $releaseDefUrl -Method Get -Headers $headers
$releaseDefinitionDetail.properties.IntegrateBoardsWorkItems.'$value' = "true"
$releaseEnvironments = $releaseDefinitionDetail.environments.name
$envCount = $releaseDefinitionDetail.environments.count
for ($i=0; $i -lt $envCount; $i++)
{
$envName = $releaseDefinitionDetail.environments[$i].name
$releaseDefinitionDetail.environments[$i].properties.LinkBoardsWorkItems.'$value' = "true"
if ($envName -contains "Dev")
{
**$releaseDefinitionDetail.environments[$i].properties.BoardsEnvironmentType.'$value' = "development"**
}
Solution 1:[1]
You're using single quotes around the variable which is interpreted as a literal string. If the property needs to be dynamically inferred, you could use Get-Member
or evaluate it as a dynamic expression with iex
.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | joelforsyth |