I have been able to do everything except deploy the release through the API. I have search all documentation and come up empty. Am I missing something?
Asked
Active
Viewed 2,200 times
1
-
as per Levi's answer. You POST to create a new release and then you PATCH that release to deploy your required environment. see: https://learn.microsoft.com/en-us/rest/api/azure/devops/release/releases/update-release-environment?view=azure-devops-rest-5.1 – timB33 Dec 09 '21 at 13:55
2 Answers
3
You can use create release rest api to deploy a new release.
POST https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/releases?api-version=5.1
See below example in powershell script:
See steps here to get Personal access token(PAT).
$url = "https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/releases?api-version=5.1"
$PAT= "Personal access token"
$base64AuthInfo= [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($PAT)"))
$body= '{
"definitionId": 3
}'
$result=Invoke-RestMethod -Uri $url -Headers @{Authorization = ("Basic {0}" -f $base64AuthInfo)} -Method post -ContentType "application/json" -Body $body
If you want to redeploy a existing stage. You can use update release environment rest api.
PATCH https://vsrm.dev.azure.com/{organization}/{project}/_apis/Release/releases/{releaseId}/environments/{environmentId}?api-version=5.1-preview.6
See below script example:
$url = "https://vsrm.dev.azure.com/{organization}/{project}/_apis/Release/releases/{releaseId}/environments/{environmentId}?api-version=5.1-preview.6"
$PAT= "Personal access token"
$base64AuthInfo= [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($PAT)"))
#set status to inProgress to redeploy the stage
$body= '{
"status": "inProgress"
}'
$result=Invoke-RestMethod -Uri $url -Headers @{Authorization = ("Basic {0}" -f $base64AuthInfo)} -Method patch -ContentType "application/json" -Body $body

Levi Lu-MSFT
- 27,483
- 2
- 31
- 43
-
With the update API you are also able to start a deployment in any environment on a release: https://learn.microsoft.com/en-us/rest/api/azure/devops/release/releases/update-release-environment?view=azure-devops-rest-5.1#start-deployment-on-an-environment – Eduardo Russo Apr 06 '22 at 13:11
0
As of now there are two endpoints to trigger Pipelines and Classic Releases.
Check this out for Release operations: https://learn.microsoft.com/en-us/rest/api/azure/devops/release/releases?view=azure-devops-rest-5.1

koushik
- 320
- 6
- 14