使用PowerShell从Azure Devops下载最新工件 - 获取BuildId
我尝试通过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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从构建中获取最新工件,我们需要提供参数
定义
和$ $ 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” - 列表:注意:分支名称参数应包括
refs/heads
作为postman的测试:
要了解正确的定义ID,您可以在网页中打开管道,在URL中:
To get the latest artifact from the build, we need to provide the parameter
definitions
and the$top
for the REST API Builds - List:Note: The branch name parameter should include the
refs/heads
As test with postman:
And if you want to know the correct definitionId, you could open the pipeline in the web page, it in the URL: