简体   繁体   English

如何将多个 json 文件导入/上传到 Azure Devops Pipeline Release and Builds?

[英]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.

相关问题 如何将多个 json 文件导入/上传到 Azure Devops Pipeline Builds? - How to import/upload multiple json files to Azure Devops Pipeline Builds? 如何将多个 json 文件导入/上传到 Azure Devops Pipeline Releases? - How to import/upload multiple json files to Azure Devops Pipeline Releases? 如何从 Azure DevOps 管道将多个发布或构建导出到桌面? - How to export multiple Release or Builds from Azure DevOps Pipeline to desktop? 从Azure DevOps发布管道中获取文件 - Grab files from Azure DevOps Release Pipeline Azure DevOps 发布管道 - Azure Devops Release Pipeline Azure Devops发布管道-未更新Azure App Service文件 - Azure Devops Release Pipeline - Azure App Service files not updated 从Azure DevOps发布管道部署Azure Function时如何修改function.json? - How to modify function.json when deploying Azure Function from Azure DevOps release pipeline? 如何通过发布管道 CMD 任务自动将文件上传到 Azure DevOps 存储库 - How to Automatically upload a file to Azure DevOps repository through a release pipeline CMD task 如何在 Azure Devops 中相同管道的两个版本之间共享文件? - How to share a file between two builds of same pipeline in Azure Devops? 作为 Azure DevOps 发布管道的一部分,从应用服务中删除文件 - Delete files from app service as part of Azure DevOps release pipeline
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM