[英]How to import/upload multiple json files to Azure Devops Pipeline Release and Builds?
I have multiple Azure DevOps release and build (.json) files saved on my desktop.我的桌面上保存了多个 Azure DevOps 发布和构建 (.json) 文件。 The script below is to add one json file.下面的脚本是添加一个 json 文件。 I am trying to import multiple build or release json files from my desktop to Azure DevOps?我正在尝试将多个构建或发布 json 文件从我的桌面导入 Azure DevOps?
Can someone please help?有人可以帮忙吗?
$token = "PAT token"
$url = "https://dev.azure.com/{organization}/{Project}/_apis/build/definitions?api-version=6.0-preview.2"
$token = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($token)"))
$JSON = @'
request body
'@
$response = Invoke-RestMethod -Uri $url -Headers @{Authorization = "Basic $token"} -Method Post -ContentType application/json -body $JSON
How to import/upload multiple json files to Azure Devops Pipeline Release and Builds?如何将多个 json 文件导入/上传到 Azure Devops Pipeline Release and Builds?
We could use powershell scripts to parse the names of these json files from your desktop folder:我们可以使用 powershell 脚本从您的桌面文件夹中解析这些 json 文件的名称:
$JsonNames = Get-ChildItem C:\Users\<UserName>\Desktop\*.json | Select-Object -ExpandProperty Name
Then we could loop this JsonNames
to import to Azure Devops Pipeline Release and Builds:然后我们可以循环这个JsonNames
以导入到 Azure Devops Pipeline Release and Builds:
ForEach ($JN in $JsonNames)
{
$token = "PAT token"
$url = "https://dev.azure.com/{organization}/{Project}/_apis/build/definitions?api-version=6.0-preview.2"
$token = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($token)"))
$JSON= Get-Content "C:\Users\<UserName>\Desktop\$($JN).json"
$response = Invoke-RestMethod -Uri $url -Headers @{Authorization = "Basic $token"} -Method Post -ContentType application/json -body $JSON
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.