![](/img/trans.png)
[英]How to import/upload multiple json files to Azure Devops Pipeline Builds?
[英]How to import/upload multiple json files to Azure Devops Pipeline Releases?
以下腳本嘗試將多個 json 文件導入 Azure DevOps Pipeline Release。
$JsonNames = Get-ChildItem C:\Users\path\Downloads\*.json | Select-Object -ExpandProperty Name
ForEach ($JN in $JsonNames)
{
$token = "PAT"
$url = "https://vsrm.dev.azure.com/{organizationName}/{ProjectName}/_apis/release/definitions?api-version=6.0"
$token = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($token)"))
$JSON= Get-Content "C:\Users\<UserName>\Desktop\$($JN).json"
echo $JSON
$response = Invoke-RestMethod -Uri $url -Headers @{Authorization = "Basic $token"} -Method Post -ContentType application/json -body $JSON
}
我收到以下錯誤消息。 我已經使用 Get Rest API 來獲取新的發布定義,更新了項目和構建 ID,但仍然收到此錯誤消息。 有沒有辦法讓腳本忽略工件 ID?
Invoke-RestMethod : {"$id":"1","innerException":null,"message":"VS402962: No artifact version ID is specified corresponding to artifact source 'Test'. Specify
a valid value and try again.","typeName":"Microsoft.VisualStudio.Services.ReleaseManagement.Data.Exceptions.InvalidRequestException,
Microsoft.VisualStudio.Services.ReleaseManagement2.Data","typeKey":"InvalidRequestException","errorCode":0,"eventId":3000}
At line:19 char:13
+ $response = Invoke-RestMethod -Uri $url -Headers @{Authorization = "B ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
根據我的測試,當您嘗試將 json 文件上傳到發布管道時,您只需更改queueid和發布定義 ID 。
例如:在發布定義名稱前更改 queueId 和發布 id。
"downloadInputs":[]},"queueId":227,"demands":
"IntegrateJiraWorkItems":{"$type":"System.String","$value":"false"}},"id":10,"name":"New release pipeline (511)","path":"\\"
盡管您必須在不同的項目中上傳發布定義 json ,但您仍然不需要更改buildid和projectid 。
然后相同的腳本將成功創建發布。
VS402962:沒有指定對應於工件源“測試”的工件版本 ID。 指定一個有效值並重試
根據錯誤消息,您可以在原始發布管道中檢查構建工件的版本。 您需要確保工件的版本存在。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.