0
votes

Does anyone know the api to get the status of the individual release task in a release?

enter image description here

I can get the status of the release itself but not the individual release tasks (PowerShell tasks in my case). https://docs.microsoft.com/en-us/rest/api/azure/devops/release/releases/get%20release?view=azure-devops-rest-6.0 Also if anyone knows where the source code is for ADO built in tasks condition. can you please share the link?

enter image description here

2

2 Answers

1
votes

Does anyone know the api to get the status of the individual release task in a release?

Method 1: You can use a REST API that is not documented:

GET https://vsrm.dev.azure.com/{organization}/{project}/_apis/Release/releases/{releaseId}/environments/{environmentId}/attempts/{attemptId}/timelines/{timelineId}/tasks

It returns a brief overview and status(succeeded, inProgress, pending, failed...) of all tasks in the release.

The response body looks like the following example:

{
    "count": 9,
    "value": [
        {
            "id": 4,
            "timelineRecordId": "d81751cc-e42f-407a-9091-f611d37df33b",
            "name": "Initialize job",
            "dateStarted": "2021-04-27T06:01:21.5233333Z",
            "dateEnded": "2021-04-27T06:01:23.32Z",
            "startTime": "2021-04-27T06:01:21.5233333Z",
            "finishTime": "2021-04-27T06:01:23.32Z",
            "status": "succeeded",
            "rank": 1,
            "lineCount": 121,
            "issues": [],
            "agentName": "Hosted Agent",
            "logUrl": "https://vsrm.dev.azure.com/{organization}/{project}/_apis/Release/releases/6/environments/6/deployPhases/6/tasks/4/logs"
        },
        {
            "id": 5,
            "timelineRecordId": "68716c38-638d-551b-6964-2da9e273edef",
            "name": "Command Line Script",
            "dateStarted": "2021-04-27T06:01:23.33Z",
            "dateEnded": "2021-04-27T06:01:28.5833333Z",
            "startTime": "2021-04-27T06:01:23.33Z",
            "finishTime": "2021-04-27T06:01:28.5833333Z",
            "status": "succeeded",
            "rank": 2,
            "lineCount": 15,
            "issues": [],
            "task": {
                "id": "d9bafed4-0b18-4f58-968d-86655b4d2ce9",
                "name": "CmdLine",
                "version": "2.182.0"
            },
            "agentName": "Hosted Agent",
            "logUrl": "https://vsrm.dev.azure.com/{organization}/{project}/_apis/Release/releases/6/environments/6/deployPhases/6/tasks/5/logs"
        },
        {
            "id": 6,
            "timelineRecordId": "fced85f1-31cf-59f2-d2e0-ccd1645b2427",
            "name": "Command Line Script",
            "dateStarted": "2021-04-27T06:01:28.5866667Z",
            "startTime": "2021-04-27T06:01:28.5866667Z",
            "status": "inProgress",
            "percentComplete": 0,
            "rank": 3,
            "issues": [],
            "task": {
                "id": "d9bafed4-0b18-4f58-968d-86655b4d2ce9",
                "name": "CmdLine",
                "version": "2.182.0"
            },
            "agentName": "Hosted Agent",
            "logUrl": ""
        }
    ]
}

Method 2: You can use the REST API Releases - Get Task Log:

GET https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/releases/{releaseId}/environments/{environmentId}/deployPhases/{releaseDeployPhaseId}/tasks/{taskId}/logs?api-version=6.0-preview.2

It returns the running log of a specific task.

The response body looks like the following example:

2021-04-27T05:50:50.3443852Z ##[section]Starting: Command Line Script
2021-04-27T05:50:50.4313144Z ==============================================================================
2021-04-27T05:50:50.4313918Z Task         : Command line
2021-04-27T05:50:50.4314555Z Description  : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
2021-04-27T05:50:50.4314878Z Version      : 2.182.0
2021-04-27T05:50:50.4315342Z Author       : Microsoft Corporation
2021-04-27T05:50:50.4315927Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
2021-04-27T05:50:50.4316336Z ==============================================================================
2021-04-27T05:50:53.2219858Z Generating script.
2021-04-27T05:50:53.2572235Z ========================== Starting Command Output ===========================
2021-04-27T05:50:53.2972287Z ##[command]"C:\Windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "D:\a\_temp\fda7641b-b8a2-4d04-8f83-94f5eda9c3b6.cmd""
2021-04-27T05:50:53.3085688Z Write your commands here
2021-04-27T05:50:53.3086888Z Hello world
2021-04-27T05:50:53.3788822Z ##[section]Finishing: Command Line Script

If anyone knows where the source code is for ADO built in tasks condition.

I don't think Azure DevOps built-in tasks have conditions source code, because conditions can be used not only for built-in tasks, but for other tasks, jobs, stages, etc... It is supported by YAML Schema and Azure DevOps classic UI pipeline, but it has nothing to do with specific tasks.

Click this github link for Azure DevOps built-in task source code.

0
votes

Each of your PowerShell tasks is an environment; therefore, you can access through the environments that is returned by "Get Release" API. See https://docs.microsoft.com/en-us/rest/api/azure/devops/release/releases/get%20release?view=azure-devops-rest-6.0#releaseenvironment