简体   繁体   English

从 azure DevOps 项目组织中提取版本

[英]Extract releases from azure DevOps projects organization

I have an Azure DevOps organization with more 300 project and I want to extract release from the org for all DevOps project.我有一个 Azure DevOps 组织,拥有 300 多个项目,我想从组织中提取所有 DevOps 项目的发布。 I have tried using below PowerShell script but it is just giving 100 record at a time.我试过使用下面的 PowerShell 脚本,但它一次只提供 100 条记录。 and also it is saying that extracted json file is not in valid format.并且还说提取的 json 文件格式无效。

Here is my PowerShell script.这是我的 PowerShell 脚本。

$token = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
$url = "https://dev.azure.com/{orgnization}/_apis/projects?api-version=6.0"
$token = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($token)"))

$response = Invoke-RestMethod -Uri $url -Headers @{Authorization = "Basic $token" } -Method Get -ContentType application/json

Foreach ($projectName in $response.value.name) {
  
    $url1 = "https://vsrm.dev.azure.com/{orgnization}/$($projectname)/_apis/release/releases?api-version=6.0"
 
    $response = Invoke-RestMethod -Uri $url1 -Headers @{Authorization = "Basic $token" } -Method Get -ContentType application/json-patch

    echo $response | ConvertTo-Json -Depth 99 |  Out-File "D:\\file.json" -Append
}

I tried adding $top parameter with first API call which works fine if I am trying in browser but in PowerShell it is not working.我尝试在第一个 API 调用中添加$top参数,如果我在浏览器中尝试,它工作正常,但在 PowerShell 中它不起作用。

https://dev.azure.com/uniperteamservices/_apis/projects?api-version=6.0&$top=500 

How can I accomplish my below two requirement?我怎样才能完成以下两个要求?

  1. How can extract all record, not just 100如何提取所有记录,而不仅仅是 100
  2. Why extracted json file is showing as invalid format when I am converting to excel?为什么当我转换为 excel 时,提取的 json 文件显示为无效格式?

If you can modify above PowerShell script for my requirement, it will be appreciated.如果您能根据我的要求修改上面的 PowerShell 脚本,将不胜感激。

Thanks谢谢

Step through your code in a debugger.在调试器中单步执行代码。

$top wrapped in double quotes will try to interpolate a variable named $top .用双引号括起来的$top将尝试插入一个名为$top的变量。 You need to escape the $ with a ` character.您需要使用 ` 字符对$进行转义。 ie IE

`$top

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM