我在管道中最后一个作业的“部署后条件”下添加了一个“调用Rest API”任务。我将需要将管道的开始和结束时间发布到其他API。获得这两个值的变量是什么?
为Rest API Post操作生成的默认标头。
{
"Content-Type":"application/json",
"PlanUrl": "$(system.CollectionUri)",
"ProjectId": "$(system.TeamProjectId)",
"HubName": "$(system.HostType)",
"PlanId": "$(system.PlanId)",
"JobId": "$(system.JobId)",
"TimelineId": "$(system.TimelineId)",
"TaskInstanceId": "$(system.TaskInstanceId)",
"AuthToken": "$(system.AccessToken)"
}
需要获取管道StartTime
和EndTime
以及Status
等
答案 0 :(得分:1)
我在powershell任务中对其进行了测试,并通过以下脚本获得了状态和startTime。
$url = "https://vsrm.dev.azure.com/{org}/{project}/_apis/release/releases/$(Release.releaseId)?api-version=5.1"
$pipeline = Invoke-RestMethod -Uri $url -Headers @{
Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN"
} -Method Get
$test0 = $pipeline.environments.deploySteps.releaseDeployPhases.deploymentJobs.job.status
Write-Host $test0
$test1 = $pipeline.environments.deploySteps.releaseDeployPhases.deploymentJobs.job.startTime
Write-Host $test1