GetAgentPoolAgentsAsync() 공개 메소드

public GetAgentPoolAgentsAsync ( int agentPoolId ) : Task>
agentPoolId int
리턴 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;
        }