使用PowerShell从Azure Devops下载最新工件 - 获取BuildId

发布于 2025-01-26 05:17:57 字数 625 浏览 4 评论 0原文

我尝试通过PowerShell从Azuredevops下载最新的工件。

这是我获得最新buildid的脚本:

$organisation="aaa"
$project="bbb"
$personalAccessToken="ccc"


$base64AuthInfo= [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($personalAccessToken)"))
$headers = @{Authorization=("Basic {0}" -f $base64AuthInfo)}


$url = "https://dev.azure.com/$organisation/$project/_apis/build/latest/1?branchName=main" 

$result = Invoke-RestMethod -Uri $url -Method Get -ContentType application/json -Headers $headers

执行此功能时,我会得到例外

找不到构建管道1。

有人可以帮助我,在哪里可以获得正确的定义iD?

I try to download the latest Artifact from AzureDevops with PowerShell.

Here is my script to get the latest buildid:

$organisation="aaa"
$project="bbb"
$personalAccessToken="ccc"


$base64AuthInfo= [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($personalAccessToken)"))
$headers = @{Authorization=("Basic {0}" -f $base64AuthInfo)}


$url = "https://dev.azure.com/$organisation/$project/_apis/build/latest/1?branchName=main" 

$result = Invoke-RestMethod -Uri $url -Method Get -ContentType application/json -Headers $headers

When I execute this, I get the exception

Build pipeline 1 was not found.

Can someone help me, where I can get the correct definitionId?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

枕花眠 2025-02-02 05:17:57

使用PowerShell从Azure Devops下载最新工件 - 获取BuildID

从构建中获取最新工件,我们需要提供参数定义$ $ top用于REST API < a href =“ https://learn.microsoft.com/en-us/rest/rest/api/azure/devops/devops/build/build/builds/list?view= azure-devops-rest-6.0” - 列表:

GET https://dev.azure.com/{organization}/{project}/_apis/build/builds?definitions={definitions}&$top={$top}&branchName={branchName}&api-version=6.0

注意:分支名称参数应包括refs/heads

作为postman的测试:

​要了解正确的定义ID,您可以在网页中打开管道,在URL中:

“在此处输入图像说明”

Download latest artifact from Azure Devops using Powershell - get buildId

To get the latest artifact from the build, we need to provide the parameter definitions and the $top for the REST API Builds - List:

GET https://dev.azure.com/{organization}/{project}/_apis/build/builds?definitions={definitions}&$top={$top}&branchName={branchName}&api-version=6.0

Note: The branch name parameter should include the refs/heads

As test with postman:

enter image description here

And if you want to know the correct definitionId, you could open the pipeline in the web page, it in the URL:

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文