public async Task <AgentPoolQueue> GetAgentPoolQueue(CancellationToken cancellationToken) { if (cachedAgentPoolQueue == null) { var projectReference = await GetProjectReferenceAsync(cancellationToken); var taskAgentClient = await GetTaskAgentClientAsync(cancellationToken); this.logger.LogDebug("Getting agent queues from taskAgentClient with queue name {QueueName}", agentPool); var agentQueues = await taskAgentClient.GetAgentQueuesAsync( project : projectReference.Id, queueName : agentPool, cancellationToken : cancellationToken ); this.logger.LogDebug("taskAgentClient returned {Count} agent queues", agentQueues.Count); cachedAgentPoolQueue = new AgentPoolQueue() { Id = agentQueues.First().Id }; this.logger.LogDebug("Cached agent queue with id {Id}", cachedAgentPoolQueue.Id); } return(cachedAgentPoolQueue); }
public async Task <AgentPoolQueue> GetAgentPoolQueue(CancellationToken cancellationToken) { if (cachedAgentPoolQueue == null) { var projectReference = await GetProjectReferenceAsync(cancellationToken); var taskAgentClient = await GetTaskAgentClientAsync(cancellationToken); var agentQueues = await taskAgentClient.GetAgentQueuesAsync( project : projectReference.Id, queueName : agentPool, cancellationToken : cancellationToken ); cachedAgentPoolQueue = new AgentPoolQueue() { Id = agentQueues.First().Id }; } return(cachedAgentPoolQueue); }
public async static void CreateBuildDefinition(string teamProject) { var tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(collectionUrl)); var bhc = tpc.GetClient <BuildHttpClient>(); string templateProject = "TEMPLATE_PROJECT"; int templateId = FindBuildDefinitionId(templateProject, "TEMPLATE_BUILD"); BuildDefinition buildDefTemplate = (await bhc.GetDefinitionAsync(templateProject, templateId)); buildDefTemplate.Project = null; buildDefTemplate.Name = "NewBuild"; var repository = buildDefTemplate.Repository; buildDefTemplate.Repository = null; repository.Url = null; repository.Id = null; repository.Name = teamProject; buildDefTemplate.Repository = repository; var queue = buildDefTemplate.Queue; buildDefTemplate.Queue = null; AgentPoolQueue newQueue = new AgentPoolQueue(); newQueue.Name = queue.Name; buildDefTemplate.Queue = newQueue; buildDefTemplate.Variables.Clear(); BuildDefinitionVariable var1 = new BuildDefinitionVariable(); var1.Value = "value"; buildDefTemplate.Variables.Add("key", var1); await bhc.CreateDefinitionAsync(buildDefTemplate, teamProject); }