gpt4 book ai didi

azure-devops - 是否可以以 excel 格式导出 azure devops 管道运行历史记录?

转载 作者:行者123 更新时间:2023-12-04 02:44:12 26 4
gpt4 key购买 nike

我想分析 azure devops 构建和发布管道运行,即构建成功或失败的数量,间隔内运行的作业数量等。如果我们可以导入构建和发布管道历史记录,则可以轻松完成此类分析excel格式。在 azure devops 中,我找不到任何功能来执行此操作。是否可以导出 excel 格式的构建和发布管道运行历史记录?

最佳答案

其实你可以从response中选择你需要的具体属性,直接导出到*.csv文件,*.csv文件可以用Microsoft excel打开。

供您引用的示例:

Param(
[string]$collectionurl = "https://dev.azure.com/{organization}",
[string]$project = "ProjectName",
[string]$user = "user",
[string]$token = "PAT/Password",
[string]$Filename = 'D:\temp\PipelineHistory.csv'
)

# Base64-encodes the Personal Access Token (PAT) appropriately
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user,$token)))

#BaseUrl
$buildsURL = "$collectionurl/$project/_apis/build/builds?api-version=5.1"

#Response
$builds = (Invoke-RestMethod -Uri $buildsURL -Method Get -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}).value

Write-host "Count of succeeded builds:" ($builds | where({$_.result -eq 'succeeded'})).count
Write-host "Count of failed builds:" ($builds | where({$_.result -eq 'failed'})).count

$results = @()

foreach($build in $builds){

$customObject = new-object PSObject -property @{
"BuildID" = $build.id
"BuildNumber" = $build.buildNumber
"Status" = $build.status
"Result" = $build.result

}

$results += $customObject
}

$results | Select `
BuildID,
BuildNumber,
Status,
Result | export-csv -Path $filename -NoTypeInformation

关于azure-devops - 是否可以以 excel 格式导出 azure devops 管道运行历史记录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57920731/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com