当它们全部通过 Azure DevOps 时,如何判断哪个作业导致部署管道失败

问题描述 投票:0回答:1

我有一个 Azure DevOps YAML 管道,其中的

deploy
作业失败了: failing pipeline

当我单击阶段列中的红色 X 时,它会显示已执行的作业: passing jobs

我点击的每个作业都没有显示失败。在 Azure DevOps UI 中的哪里可以找到导致管道失败的操作?

供参考,我的管道 YAML 如下:

jobs:
- deployment: 
  environment:
    name: XXX-XXX-BLD
    resourceType: virtualMachine
  strategy:
    rolling:
      maxParallel: 5  #for percentages, mention as x%
      deploy:
        steps:
        - powershell: |
            # Use the Windows certificate store for Git's SSL certificates for both
            # agents (build and deploy).
            & C:\agents\build\externals\git\cmd\git.exe config --global http.sslBackend schannel
            & C:\agents\deploy\externals\git\cmd\git.exe config --global http.sslBackend schannel
        - powershell: | 
            #Requires -RunAsAdministrator 
            & choco upgrade buildstation --pre --no-progress
azure tfs
1个回答
0
投票

您可以使用 Timeline - Get REST API 获取本次运行的详细状态。

PowerShell 脚本示例:

$organization = "orgname"
$project = "projectname"
$buildId = ""
$PAT = ""

$PATGetBytes = [System.Text.Encoding]::ASCII.GetBytes(":$PAT")
$Authentication = [System.Convert]::ToBase64String($PATGetBytes)
$Headers = @{Authorization = ("Basic {0}" -f $Authentication) }
# Define the URL for the Timeline API
$url = "https://dev.azure.com/$organization/$project/_apis/build/builds/$buildId/timeline/?api-version=7.1-preview.2"

# Make the API request
$response = Invoke-RestMethod -Uri $url -Method Get -ContentType "application/json" -Headers $Headers 

# Parse the response to get the records
$status = $response.records 

# Output
$status | ForEach-Object {
    Write-Output ("Result : " + $_.result + ", State: " + $_.state  + ", Type: " + $_.type + ", Name : " + $_.name )
}
© www.soinside.com 2019 - 2024. All rights reserved.