Azure SDK for .NET 中是否有一个或一组属性来确定 Azure DevOps 中的管道是使用经典架构还是使用 YAML?
您可以将 .NET 客户端库用于 Azure DevOps。
您需要在项目中安装以下具有最新可状态版本的 NuGet 包:
Microsoft.TeamFoundationServer.Client
Microsoft.VisualStudio.Services.Client
Microsoft.VisualStudio.Services.InteractiveClient
下面是 C# 代码示例作为参考。
using Microsoft.Azure.Pipelines.WebApi;
using Microsoft.VisualStudio.Services.Common;
using Microsoft.VisualStudio.Services.WebApi;
. . .
public static void getPipeline(string orgName, string projName, int pipID, string pat)
{
try {
var orgUrl = new Uri($"https://dev.azure.com/{orgName}");
VssConnection connection = new VssConnection(orgUrl, new VssBasicCredential(string.Empty, pat));
PipelinesHttpClient pipClient = connection.GetClient<PipelinesHttpClient>();
var get_pipe = pipClient.GetPipelineAsync(projName, pipID).Result;
var type = get_pipe.Configuration.Type.ToString();
Console.Write($"The type of pipeline {pipID} is {type}.");
}
catch(Exception ex) {
Console.Write(ex.ToString());
}
}
当管道是YAML管道时,type的返回值为'
yaml
'(或'Yaml
')。否则,它不是 YAML 管道。
对应的REST API是“Pipelines - Get”。