我想用API调用自动化Azure管道的队列,获取关于管道/构建/作业状态的信息,
azure-devops-rest-api也只提到VSTS和TFS:
是一组API,允许管理帐户以及TFS 2015和2017服务器。除了这两个结果,我只找到其他版本或翻译的各种副本-和许多无关的文件,是关于Azure在一般情况下。
我只是在用错误的词搜索吗?
有用于Azure DevOps管道的实际API吗?
它有可用的API资源管理器吗?
它有适合JavaScript、Ruby或PHP等语言的客户端吗?
发布于 2018-12-11 14:49:17
似乎我不擅长搜索:
通过API触发Azure管道的构建和启动构建并通过VSTS Rest传递变量 (通过在StackOverflow上搜索[azure-pipelines] api)向我指出了上面提到的Azure DevOps服务REST。
发布于 2020-12-09 09:45:53
我也一直致力于自动化DevOps管道,并一直在这里结束。其中一些信息似乎已经过时。在我写这篇文章的时候,我相信Microsoft中的这篇文章是最新的。为了让它正常工作,我确实需要稍微挠头一点,但最后还是得到了这段代码。
public static async Task InitiatePipeline(CancellationToken cancellationToken = default)
{
using(HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var token = Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(string.Format("{0}:{1}", "", AppSettings.DevOpsPAT)));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", token);
var repoGuid = "Put GUID Here"; // You can get GUID for repo from the URL when you select the rpo of interest under Repos is Project Settings
var bodyJson = @"{
""parameters"": {
""parameterName"": ""parameterValue""
},
""variables"": {},
""resources"": {
""repositories"": {
""self"": {
""repository"": {
""id"": """ + repoGuid + @""",
""type"": ""azureReposGit""
},
""refName"": ""refs/heads/master""
}
}
}
}";
var bodyContent = new StringContent(bodyJson, Encoding.UTF8, "application/json");
var pipeLineId = 61; // Can get this from URL when you open the pipeline of interest in Azure DevOps
var response = await client.PostAsync($"https://dev.azure.com/ORG_NAME/PROJECT_NAME/_apis/pipelines/{pipeLineId}/runs?api-version=6.0-preview.1", bodyContent, cancellationToken);
response.EnsureSuccessStatusCode();
}
}发布于 2021-05-18 22:37:47
我也遇到了这些问题,最后做了一个API的powershell包装器,然后将它封装到Azure DevOps管道模板中。我刚刚出版了它供任何人使用。我希望任何发现这个线程的人都能发现此模板很有用。
https://stackoverflow.com/questions/53726566
复制相似问题