简体   繁体   English

以编程方式访问 Azure DevOps 变量组而不使用 REST api

[英]Programmatically access Azure DevOps variable groups without using REST api

Is there a way to programmatic access the Azure DevOps variable groups by using C# class wrappers rather than the REST API provide here:有没有办法通过使用 C# class 包装器而不是 REST API 在此处提供以编程方式访问 Azure DevOps 变量组:

[https://learn.microsoft.com/en-us/rest/api/azure/devops/distributedtask/variablegroups?view=azure-devops-rest-5.0][1] [https://learn.microsoft.com/en-us/rest/api/azure/devops/distributedtask/variablegroups?view=azure-devops-rest-5.0][1]

You need to use the DistributedTask library.您需要使用 DistributedTask 库。 Here is an example code fragment这是一个示例代码片段

using Microsoft.VisualStudio.Services.WebApi;
using Microsoft.TeamFoundation.DistributedTask.WebApi;

// Connect to Azure DevOps Services
var connection = new VssConnection(new Uri(collectionUri), creds);
TaskAgentHttpClient TaskAgentClient = connection.GetClient<TaskAgentHttpClient>();

// get variable groups
List<Microsoft.TeamFoundation.DistributedTask.WebApi.VariableGroup> vargrps = TaskAgentClient.GetVariableGroupsAsync(project: projectName).Result;

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

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