use of jetbrains.buildServer.AgentRestrictor in project teamcity-rest by JetBrains.
the class Build method getAgent.
@XmlElement(name = "agent")
public Agent getAgent() {
return ValueWithDefault.decideDefault(myFields.isIncluded("agent", false), () -> {
if (myBuild != null) {
if (myBuild.isAgentLessBuild())
return null;
SBuildAgent agent = myBuild.getAgent();
return new Agent(agent, myFields.getNestedField("agent"), myBeanContext);
}
if (myQueuedBuild != null) {
final AgentRestrictor agentRestrictor = myQueuedBuild.getAgentRestrictor();
if (agentRestrictor != null) {
if (agentRestrictor.getType() == AgentRestrictorType.SINGLE_AGENT) {
SBuildAgent agent = myQueuedBuild.getBuildAgent();
if (agent != null) {
return new Agent(agent, myFields.getNestedField("agent"), myBeanContext);
}
}
if (agentRestrictor.getType() == AgentRestrictorType.AGENT_POOL) {
final int agentPoolId = agentRestrictor.getId();
final AgentPool agentPool = myBeanContext.getSingletonService(AgentPoolFinder.class).getAgentPoolById(agentPoolId);
return new Agent(agentPool, myFields.getNestedField("agent"), myBeanContext);
}
if (agentRestrictor.getType() == AgentRestrictorType.CLOUD_IMAGE) {
final int agentTypeId = agentRestrictor.getId();
final SAgentType agentType = AgentFinder.getAgentType(String.valueOf(agentTypeId), myBeanContext.getSingletonService(AgentTypeFinder.class));
return new Agent(agentType, myFields.getNestedField("agent"), myBeanContext);
}
}
}
return null;
});
}
Aggregations