azure-devops-dotnet-samples icon indicating copy to clipboard operation
azure-devops-dotnet-samples copied to clipboard

How to change variable in a variable group

Open PatrickGrub opened this issue 5 years ago • 2 comments

I want to change via C# in Azure Devops in a specific Variable Group a specific variable: https://docs.microsoft.com/en-us/rest/api/azure/devops/distributedtask/variablegroups?view=azure-devops-rest-5.0

How can I get started? Which VssHttpClientBase do I need? Examples?

PatrickGrub avatar Oct 26 '20 12:10 PatrickGrub

You'll need to install Microsoft.TeamFoundation.DistributedTask.WebApi nuget package, reference Microsoft.TeamFoundation.DistributedTask.WebApi

then you can initialise TaskAgentHttpClient

var devopsConnection = new VssConnection(new Uri(devopsUrl), new VssBasicCredential(string.Empty, devopsToken));
var taskClient = devopsConnection.GetClient<TaskAgentHttpClient>();
var variableGroups = taskClient.GetVariableGroupsAsync(project.Id).Result;

then use methods on these to modify as you desire.

ydbendasan avatar Apr 29 '21 18:04 ydbendasan

Not impersonating didn't know.

DavidBergeron-eng avatar Sep 02 '21 20:09 DavidBergeron-eng