You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何获取项目/发布的Options>Integrations配置参数并排查缺失项

解决方案:获取Azure DevOps发布管道的「向Boards报告状态」配置

一、用Azure DevOps REST API直接查询

这个配置藏在发布管道的releaseDefinitions接口的reportingSettings节点里,是官方API支持的字段,具体操作如下:

1. 先获取组织下所有项目(用于批量遍历)

用PowerShell调用API拿到项目列表,需要提前准备好PAT令牌(权限至少要「发布」的读取权限):

$orgUrl = "https://dev.azure.com/你的组织名称"
$patToken = "你的PAT令牌"
$authHeader = @{Authorization = "Basic " + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$patToken"))}

# 获取所有项目
$allProjects = Invoke-RestMethod -Uri "$orgUrl/_apis/projects?api-version=7.1-preview.4" -Headers $authHeader -Method Get

2. 遍历项目提取发布管道的Boards报告配置

对每个项目,调用发布定义API,提取关键配置字段:

foreach ($proj in $allProjects.value) {
    $projId = $proj.id
    $releasePipelines = Invoke-RestMethod -Uri "$orgUrl/$projId/_apis/release/definitions?api-version=7.1-preview.7" -Headers $authHeader -Method Get
    
    foreach ($pipeline in $releasePipelines.value) {
        $reportingCfg = $pipeline.reportingSettings
        Write-Host "项目: $($proj.name) | 管道名: $($pipeline.name)"
        Write-Host "  启用Boards报告: $($reportingCfg.enableReporting)"
        Write-Host "  目标Boards项目: $($reportingCfg.projectName ?? '当前项目')"
        Write-Host "-------------------------"
    }
}

3. 字段对应关系

  • enableReporting:就是「启用向Boards报告状态」的开关,True为开启,False为关闭
  • projectName:如果配置了跨项目报告,这里显示目标项目名称;同项目报告时该字段为空,直接显示「当前项目」即可

二、AZ CLI替代方案

目前az pipelines release系列命令没有直接输出这个配置,但可以用az devops invoke调用API来实现:

az devops invoke --org "https://dev.azure.com/你的组织名称" --area release --resource definitions --api-version 7.1-preview.7 --http-method GET --query "value[].{管道名称:name, 启用报告:reportingSettings.enableReporting, 目标项目:reportingSettings.projectName}"

三、批量导出排查(CSV格式)

如果需要整理成表格方便排查缺失配置,可以修改PowerShell脚本导出CSV:

$outputList = @()
foreach ($proj in $allProjects.value) {
    $projId = $proj.id
    $releasePipelines = Invoke-RestMethod -Uri "$orgUrl/$projId/_apis/release/definitions?api-version=7.1-preview.7" -Headers $authHeader -Method Get
    
    foreach ($pipeline in $releasePipelines.value) {
        $outputItem = [PSCustomObject]@{
            项目名称 = $proj.name
            发布管道名称 = $pipeline.name
            启用Boards报告 = $pipeline.reportingSettings.enableReporting
            目标Boards项目 = $pipeline.reportingSettings.projectName ?? "当前项目"
        }
        $outputList += $outputItem
    }
}
$outputList | Export-Csv -Path "Boards报告配置排查结果.csv" -Encoding UTF8 -NoTypeInformation

内容的提问来源于stack exchange,提问作者Matías Rodríguez

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 07:37:16