Search code examples
azure-devopsazure-pipelinesazure-pipelines-release-pipelineazure-devops-rest-apiazure-pipelines-tasks

How to get azure devops release pipeline deployment logs using Azure DevOps REST API?


I came across two REST APIs but not sure will fetch the deployment logs.

GET https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/releases/{releaseId}/logs?api-version=5.1-preview.2

GET https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/releases/{releaseId}/environments/{environmentId}/deployPhases/{releaseDeployPhaseId}/tasks/{taskId}/logs?api-version=5.1-preview.2
  1. I tried with the first REST API. It is retrieving the data in form of transfer-encoded format. How to retrieve the real data from the body in NodeJS?
  2. In order to check the second REST API, I didn't have values for releaseDeployPhaseId and taskId. I didn't get those information in Azure DevOps Release Pipeline portal.

Can anyone help me on this? Thanks in advance!


Solution

  • According to the test results, it is currently only possible to obtain the plain text release log through the second API.

    You can get deployPhaseId and taskId according to the api provided by Shayki, deployPhaseId refers to the agent job id in the stage. The shortcoming of the second rest api is that it cannot get the complete release log, it can only get the log of one task.

    If you do not get the release log through the rest api, you can download the complete log from the web ui through the Download all logs button.

    Regarding the first rest api, I tested the url in the browser: https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/releases/{releaseId}/logs, it automatically downloaded a log.zip file to the local. Test in postman, it returned unrecognizable code.

    enter image description here