I'm using the TFS 2017 API to get the latest deploy log for my releases.
I'm using this pattern:
GET https://{instance}/{project}/_apis/release/releases/{releaseId}/environments/{environmentId}/tasks?api-version={version}
It works well for the first deployment.
When a task fails, and I redeploy it, it returns the log of the first deployment, not the current deployment.
I want the log of the last deployment for each task, not the first deployment.
You have to add the deployPhases in the Rest API URL:
GET https://{instance}/{project}/_apis/release/releases/{releaseId}/environments/{environmentId}/deployPhases/{deployPhaseId}/tasks?api-version={version}
For example, if you deploy the environment three times and you want to get the information for the third deployment, then the deployPhaseId
is 3
.