因此,我可以获得构建详细信息,但它不包含有关构建作业的任何信息。例如,每个构建作业都在构建代理上运行 - 我如何使用 REST Api 获取此部分?
我们谈论的是 vNext 构建,而不是 XAML。
在邮递员中,我设置了简单的请求来访问 Azure DevOps API,通过 Azure AD 使用 OAuth 2.0 安全 https://learn.microsoft.com/en-us/rest/api/azure/devops/core/projects/list?view= azure-devops-rest-5.1 在 Azure AD 应用程序设置上,有权在用户同意的情况下访问 Azure DevOps API
我正在获取令牌,但是 Azure DevOps API 不断返回代码 203,并使用登录 html 而不是 json 响应。如果有任何建议,我将不胜感激
谢谢
邮递员请求
GET /[some_org]/_apis/projects?api=5.1 HTTP/1.1
Host: dev.azure.com
Authorization: Bearer [something]
User-Agent: PostmanRuntime/7.17.1
Accept: */*
Cache-Control: no-cache
Postman-Token: [something]
Accept-Encoding: gzip, deflate
Cookie: VstsSession=[something]
Referer: https://dev.azure.com/[some_org]/_apis/projects?api=5.1
Connection: keep-alive cache-control: no-cache
Run Code Online (Sandbox Code Playgroud)
我正在努力弄清楚如何使用 API 创建启用自动完成功能的拉取请求,如果有人可以提供发布的 JSON 示例以启用自动完成功能,那就太棒了。
我尝试过设置autoCompleteSetBy属性,也尝试过属性中的一大堆设置 completionOptions。
出于开发目的,我们需要通过 Visual Studio 在本地启动 PowerShell 脚本,其任务是获取特定分支的最后一个构建 ID。
到目前为止,我已经尝试了很多基于此的选择:
$WebClient = New-Object Net.WebClient
Write-Host "Downloading patches and binaries"
Write-Host "Get ID"
$url = "https://oldrepo.visualstudio.com/ProjectA/_apis/build/latest/14?branchName=master"
$result = $WebClient.DownloadString($url)
Write-Host $result
Run Code Online (Sandbox Code Playgroud)
但是,该result值返回 azure 的登录页面,而不是我的存储库。如果我将相同的网址粘贴到浏览器中,我确实会得到好的页面。
我认为请求中传递了某种 cookie/AD 凭据,但我没有通过开发人员工具看到任何相关内容。
我尝试手动设置 WebClient 对象的凭据,如下所示:
#$creds = Get-Credential -UserName "User" -Message "Login"
#$WebClient.Credentials = $creds
#$WebClient.UseDefaultCredentials = $true
Run Code Online (Sandbox Code Playgroud)
但无济于事。我缺少什么?
I\xe2\x80\x99m 构建一个从我们的 Azure DevOps 板获取信息的应用程序。任务之一是获取给定列中存在的所有票证。
\n我\xe2\x80\x99m花了很多时间阅读他们的文档,但所有方法都依赖于你传递你想要返回的IDS,而我\xe2\x80\x99m寻找的是API来告诉我知道给定列中确实存在哪些工作项。
\n我需要找到与 Azure DevOps API 的 Artifact 资源一起使用的 Feed 的 ID。我当前使用此 URL 查看我的组织中的所有 Artifact feed。
https://feeds.dev.azure.com/{organization}/{project}/_apis/packaging/feeds?api-version=6.0-preview.1
Run Code Online (Sandbox Code Playgroud)
这将返回所有项目范围的 Feed,但不返回组织范围的 Feed。我尝试使用下面的链接访问该链接,但没有成功,它总是告诉我提供的 ID 不存在。
https://feeds.dev.azure.com/{organization}/{project}/_apis/packaging/feeds/{feedId}?api-version=6.0-preview.1
Run Code Online (Sandbox Code Playgroud)
所以我的问题是:有没有办法使用 DevOps API 从组织范围的 Feed 访问信息/包?
我正在编写脚本来列出所有发布管道名称
我在 Microsoft 文档中找到了这个rest api -
获取https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/releases?api-version=6.0
这列出了每个发布管道的所有版本
使用以下管道休息 API 我可以获得仅构建管道的计数和信息 -
获取https://dev.azure.com/{organization}/{project}/_apis/pipelines?api-version=6.0-preview.1
是否有类似的剩余 api 可用,如管道 api 来获取所有发布管道的计数和信息(并非每个发布管道的所有发布)
或者有没有办法使用单个rest api 来构建和发布所有管道?
azure-devops azure-pipelines-release-pipeline azure-devops-rest-api
我一直致力于创建一个 API,它可以以编程方式在 Azure Devops 中创建/更新工作项。我已经能够创建一个工作项并填充几乎所有字段。我在设置状态时遇到问题。
当我使用任何状态名称(如“活动”、“关闭”、“拒绝”)向 Azure Devops Rest api 创建 POST 请求时,它会引发 400 错误请求错误。
我不知道我是否遗漏了任何内容,或者我尝试设置该值的方式是否有问题。
{
"op" : "add",
"path": "/fields/System.State",
"value"="Active",
}
Run Code Online (Sandbox Code Playgroud) 如何设置链接的工作项以在发布完成后自动更改状态。
例如,状态处于 DEV 状态,代码通过发布管道部署到 QA 分支。如果发布管道成功,我希望我的工作项自动更改状态。
tfs workitem azure-devops azure-pipelines azure-devops-rest-api
我正在尝试使用python 3.6的VisualStudioOnline REST API.(使用python 2.x的大量示例)
python脚本响应是通用的html登录页面.
我已经使用REST控制台Chrome插件测试了此脚本生成的url,并且使用我的个人访问令牌工作正常.
import json
import base64
import urllib.request
personal_access_token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
headers = {}
headers['Content-type'] = "application/json"
headers['Authorization'] = b'Basic ' +
base64.b64encode(personal_access_token.encode('utf-8'))
instance = "mycompany.visualstudio.com"
project = "MyProject"
repository ="MyRepository"
pullrequest = "3468"
api_version = "3.0"
repositories_url = ("https://%s/DefaultCollection/%s/_apis/git/repositories?
api-version=%s" % (instance, project, api_version))
print(repositories_url)
request = urllib.request.Request(repositories_url, headers=headers)
opener = urllib.request.build_opener()
response = opener.open(request)
print(response.read())
Run Code Online (Sandbox Code Playgroud)
Powershell示例
如何使用个人访问令牌对Visual Studio Team Services进行身份验证?
C#和curl示例
https://www.visualstudio.com/en-us/docs/integrate/get-started/authentication/pats
restful-authentication python-3.x azure-devops azure-devops-rest-api
azure-devops ×9
workitem ×2
azure ×1
azure-pipelines-release-pipeline ×1
oauth-2.0 ×1
odata ×1
postman ×1
powershell ×1
python-3.x ×1
rest ×1
tfs ×1