GetAgentPoolAgentsAsync() public method

public GetAgentPoolAgentsAsync ( int agentPoolId ) : Task>
agentPoolId int
return Task>
示例#1
0
        private static async Task <ApplicationResult> RunAsync(Options options)
        {
            var client = new TeamCityClient(new Uri(options.Server));

            // Prepare the agent.
            Agent agent = await PrepareAgentAsync(options, client);

            // Optionally, add the agent to the agent pool.
            if (options.AgentPoolName != null)
            {
                var agentPools = await client.GetAgentPoolsAsync();

                var agentPool = agentPools.FirstOrDefault(x => string.Equals(
                                                              x.Name,
                                                              options.AgentPoolName,
                                                              StringComparison.OrdinalIgnoreCase));

                if (agentPool == null)
                {
                    Console.WriteLine($"No agent pool '{options.AgentPoolName}' was found.");
                    return(ApplicationResult.NoMatchingAgentPool);
                }

                var agents = await client.GetAgentPoolAgentsAsync(agentPool.Id);

                if (!agents.Any(x => x.Id == agent.Id))
                {
                    Console.WriteLine($"Adding agent '{agent.Name}' to agent pool '{agentPool.Name}'...");
                    await client.AddAgentToAgentPoolAsync(agentPool.Id, agent.Id);
                }
                else
                {
                    Console.WriteLine($"The agent '{agent.Name}' is already in agent pool '{agentPool.Name}'.");
                }
            }

            return(ApplicationResult.Success);
        }
示例#2
0
        private static async Task<ApplicationResult> RunAsync(Options options)
        {
            var client = new TeamCityClient(new Uri(options.Server));

            // Prepare the agent.
            Agent agent = await PrepareAgentAsync(options, client);
            
            // Optionally, add the agent to the agent pool.
            if (options.AgentPoolName != null)
            {
                var agentPools = await client.GetAgentPoolsAsync();
                var agentPool = agentPools.FirstOrDefault(x => string.Equals(
                    x.Name,
                    options.AgentPoolName,
                    StringComparison.OrdinalIgnoreCase));

                if (agentPool == null)
                {
                    Console.WriteLine($"No agent pool '{options.AgentPoolName}' was found.");
                    return ApplicationResult.NoMatchingAgentPool;
                }

                var agents = await client.GetAgentPoolAgentsAsync(agentPool.Id);
                if (!agents.Any(x => x.Id == agent.Id))
                {
                    Console.WriteLine($"Adding agent '{agent.Name}' to agent pool '{agentPool.Name}'...");
                    await client.AddAgentToAgentPoolAsync(agentPool.Id, agent.Id);
                }
                else
                {
                    Console.WriteLine($"The agent '{agent.Name}' is already in agent pool '{agentPool.Name}'.");
                }
            }

            return ApplicationResult.Success;
        }