如何 import/upload 多个 json 文件到 Azure Devops 管道发布和构建?
How to import/upload multiple json files to Azure Devops Pipeline Release and Builds?
我的桌面上保存了多个 Azure DevOps 发布和构建 (.json) 文件。下面的脚本是添加一个 json 文件。我正在尝试将多个构建或发布 json 文件从我的桌面导入到 Azure DevOps?
有人可以帮忙吗?
$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?
我们可以使用 powershell 脚本从您的桌面文件夹中解析这些 json 文件的名称:
$JsonNames = Get-ChildItem C:\Users\<UserName>\Desktop\*.json | Select-Object -ExpandProperty Name
然后我们可以循环此 JsonNames
以导入到 Azure Devops 管道发布和构建:
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
}
我的桌面上保存了多个 Azure DevOps 发布和构建 (.json) 文件。下面的脚本是添加一个 json 文件。我正在尝试将多个构建或发布 json 文件从我的桌面导入到 Azure DevOps?
有人可以帮忙吗?
$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?
我们可以使用 powershell 脚本从您的桌面文件夹中解析这些 json 文件的名称:
$JsonNames = Get-ChildItem C:\Users\<UserName>\Desktop\*.json | Select-Object -ExpandProperty Name
然后我们可以循环此 JsonNames
以导入到 Azure Devops 管道发布和构建:
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
}