简体   繁体   中英

Azure devops release edit bulk 110

Hello I have 145 releases And I have to do an equal action for everyone for example add a certain variable and edit a certain line.

Is there a way to control everyone with a script?

I checked for a template, but it creates the release from 0 and does not edit it. Can a script in PS or Python be a solution? I did not find any information on Google about it, other than an export release template.

Azure devops release edit bulk 110

You could use the REST API Definitions - Update to update the release pipeline:

PUT https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/definitions/{DefinitionsId}?api-version=6.0

And if we want to batch modify the release pipeline, we need to get each ID of the release pipeline with REST API Definitions - List :

GET https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/definitions?api-version=6.0

Then we could iterate through each Rlease ID obtained.

I provide a rough code for your better reading:

$connectionToken="PAT"
$base64AuthInfo= [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($connectionToken)"))

$ReleasePipelineUrl = "https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/definitions?api-version=6.0" 

Write-Host "URL: $ReleasePipelineUrl"

$ReleasePipelines = (Invoke-RestMethod -Uri $PipelineUrl -Method Get -UseDefaultCredential -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)})

$ReleasePipelinesId = $ReleasePipelines.value.id

Write-Host "ReleasePipelinesId = $ReleasePipelinesId"

ForEach ($Pt in $ReleasePipelinesId)

{
    $baseUrl = "https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/definitions/$($Pt)?api-version=6.0"                   
    $pipeline = (Invoke-RestMethod -Uri $baseUrl -Method Get -UseDefaultCredential -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)})
     
     Write-Host "URL: $baseUrl"

     $pipeline.variables.TestValue.value = "$buildNumber"

####****************** update the modified object **************************
$json = @($pipeline) | ConvertTo-Json -Depth 99


Write-Host "URL: $json "

$updatedef = Invoke-RestMethod -Uri $url -Method Put -Body $json -ContentType "application/json" -Headers @{Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN"}

write-host "==========================================================" 
Write-host "The value of Varialbe 'TestValue' is updated to" $updatedef.variables.TestValue.value


}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM