有人知道获取发布中单个发布任务状态的api吗?
方法一:可以使用没有文档的REST API:
GET https://vsrm.dev.azure.com/{organization}/{project}/_apis/Release/releases/{releaseId}/environments/{environmentId}/attempts/{attemptId}/timelines/{timelineId}/tasks
它返回发布中所有任务的简要概述和状态(成功、进行中、待处理、失败...)。
响应正文类似于以下示例:
{
"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": ""
}
]
}
方法2:可以使用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
它返回特定任务的运行日志。
响应正文类似于以下示例:
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
如果有人知道 ADO 内置任务条件的源代码在哪里。
我不认为 Azure DevOps 内置任务有条件源代码,因为条件不仅可以用于内置任务,还可以用于其他任务、作业、阶段等... YAML 支持Schema 和 Azure DevOps 经典 UI 管道,但它与特定任务无关。
单击this github link 获取 Azure DevOps 内置任务源代码。