public interface AgentManager
LocalBuildAgent and PipelineDefinition funnily enough. The class is fully synchronized.| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_AGENT_NAME |
| Modifier and Type | Method and Description |
|---|---|
void |
abandonBuild(BuildAgent remoteAgent,
boolean agentStartingUp) |
boolean |
allowNewElasticAgent()
Allow an elastic agent to register and come online? Based on licensing restrictions.
|
boolean |
allowNewElasticAgents(int numOfAgentsToCreate)
Allow a specified number of elastic agents to register and come online? Based on licensing restrictions.
|
boolean |
allowNewLocalAgent()
Allow a local agent to come online? Based on licensing restrictions.
|
boolean |
allowNewRemoteAgent()
Allow a remote agent to register and come online? Based on licensing restrictions.
|
boolean |
allowNewRemoteAgents(int numAgentsToCreate)
Allow a specified number of remote agents to register and come online? Based on licensing restrictions.
|
boolean |
checkPipelinesAreDisabled() |
void |
createDefaultAgent()
sets up a default local agent if no local agent exists
|
void |
createLocalAgent(LocalAgentDefinition pipelineDefinition)
Create a new local agent.
|
void |
disableAllAgents()
Disable all pipelines
|
void |
enableAllAgents()
Enable all pipelines
|
<T> T |
executeIfIdle(Callable<T> callable)
Executes a given
Callable only if no builds are in progress. |
Map<Long,PipelineDefinition> |
findAllAgentsForAgentIds(Collection<Long> agentIds)
Returns a Map of
PipelineDefinitions keyed by their id |
Collection<BuildAgent> |
getActiveAndEnabledAgents()
Returns agents that are enabled and online
|
BuildAgent |
getAgent(long agentId) |
long |
getAgentCount(Class<? extends PipelineDefinition> agentDefinitionClass)
Retrieves the amount of agents of given type stored in the database
|
PipelineDefinition |
getAgentDefinition(Long agentId) |
PipelineDefinition |
getAgentDefinitionByName(String name)
Retrieve a pipelineDefinition by name.
|
List<PipelineDefinition> |
getAgentDefinitionsWithNameLike(String likeName)
Return a list of agents whose name is like the provided string.
|
List<BuildAgent> |
getAllAgents() |
List<ElasticAgentDefinition> |
getAllElasticAgentDefinitions(Collection<String> instanceIds)
Retrieve elastic agent definitions from db.
|
List<ElasticAgentDefinition> |
getAllElasticAgentDefinitions(int firstResult,
int maxResults)
Retrieve most recently terminated elastic agent definitions from db, ordered by termination time, descending.
|
List<LocalBuildAgent> |
getAllLocalAgents()
Returns all
LocalBuildAgent objects |
List<BuildAgent> |
getAllNonElasticAgents() |
List<PipelineDefinition> |
getAllPersistedAgentDefinitions()
Retrieves a list of all agent definitions stored in the database.
|
List<BuildAgent> |
getAllRemoteAgents()
Gets all remote agents in the system.
|
List<BuildAgent> |
getAllRemoteAgents(boolean onlineOnly)
Get remote agents.
|
Collection<BuildAgent> |
getBusyBuildAgents()
Gets a collection agents that are currently building or cancelling a build
|
Collection<BuildAgent> |
getElasticActiveAndEnabledAgents()
Returns elastic agents that are enabled and online
|
Collection<LocalBuildAgent> |
getLocalActiveAndEnabledAgents()
Returns local agents that are enabled and online
|
LocalBuildAgent |
getLocalAgent(long pipelineId)
Returns the pipeline that matches the passed id
|
List<BuildAgent> |
getOnlineElasticAgents()
Retrieve all online elastic build agents.
|
Collection<BuildAgent> |
getRemoteActiveAndEnabledAgents()
Returns remote agents that are enabled and online
|
void |
initAgents()
Inits the local agents Must be ran before any other methods.
|
void |
onAgentReturning(BuildAgent agent)
Performs any other operations required when an agent goes offline, such as updating the status and shutdown
time.
|
void |
removeAgent(long agentId)
Removes the passed agent
|
void |
saveAnyPipeline(PipelineDefinition pipelineDefinition)
Stores a pipeline
PipelineDefinition of any type (elastic, local, remote)
AgentConfigurationUpdateEvent is fired after the pipeline is saved |
void |
saveAnyPipeline(PipelineDefinition pipelineDefinition,
AgentConfigurationUpdatedEventFactory eventFactory)
Stores a pipeline
PipelineDefinition of any type (elastic, local,
remote) |
void |
saveElasticPipeline(ElasticAgentDefinition pipelineDefinition)
Stores the elastic
PipelineDefinition |
void |
savePipeline(PipelineDefinition pipelineDefinition)
Stores the
PipelineDefinition. |
void |
savePipeline(PipelineDefinition pipelineDefinition,
AgentConfigurationUpdatedEventFactory eventFactory)
Stores the
PipelineDefinition. |
void |
saveReturningElasticPipeline(ElasticAgentDefinition elasticDefinition)
Stores the elastic
PipelineDefinition of a returning elastic agent. |
void |
startLocalAgents()
Starts all current
LocalBuildAgent objects |
void |
stopAgent(BuildAgent agent)
Performs any other operations required when an agent goes offline, such as updating the status and shutdown
time.
|
void |
stopLocalAgents()
Stops all
LocalBuildAgent |
boolean |
updateAgentStatusIfResultReturnPossibleAfterServerRestart(long agentId,
ResultKey resultKey,
String displayName,
long deploymentResultId)
Checks if agent is capable of 'surviving' a server restart, i.e.
|
static final String DEFAULT_AGENT_NAME
void createDefaultAgent()
void initAgents()
void startLocalAgents()
LocalBuildAgent objectsvoid stopLocalAgents()
throws InterruptedException
LocalBuildAgentInterruptedException@NotNull List<LocalBuildAgent> getAllLocalAgents()
LocalBuildAgent objectsLocalBuildAgent objects, or an empty
collection if none exists.@NotNull List<BuildAgent> getAllRemoteAgents()
@NotNull List<BuildAgent> getAllRemoteAgents(boolean onlineOnly)
onlineOnly - - only return those agents which are online currently.@NotNull List<ElasticAgentDefinition> getAllElasticAgentDefinitions(int firstResult, int maxResults)
long getAgentCount(Class<? extends PipelineDefinition> agentDefinitionClass)
agentDefinitionClass - agent type@NotNull List<ElasticAgentDefinition> getAllElasticAgentDefinitions(@NotNull Collection<String> instanceIds)
instanceIds - the instances ids on which the agents were running@NotNull List<BuildAgent> getOnlineElasticAgents()
@NotNull List<BuildAgent> getAllAgents()
@NotNull List<BuildAgent> getAllNonElasticAgents()
@NotNull Collection<BuildAgent> getBusyBuildAgents()
BuildAgent@NotNull Collection<BuildAgent> getActiveAndEnabledAgents()
BuildAgent@NotNull Collection<BuildAgent> getRemoteActiveAndEnabledAgents()
BuildAgent@NotNull Collection<BuildAgent> getElasticActiveAndEnabledAgents()
BuildAgent@NotNull Collection<LocalBuildAgent> getLocalActiveAndEnabledAgents()
LocalBuildAgentvoid savePipeline(PipelineDefinition pipelineDefinition)
PipelineDefinition. Updates any caches so calls to getLocalAgent(long) will return the LocalBuildAgent returns with
the new definitionpipelineDefinition - - Must not be nullvoid savePipeline(PipelineDefinition pipelineDefinition, @Nullable AgentConfigurationUpdatedEventFactory eventFactory)
PipelineDefinition. Updates any caches so calls to getLocalAgent(long) will return the LocalBuildAgent returns with
the new definitionpipelineDefinition - - Must not be nulleventFactory - event factory used to create event sent after the pipeline is savedvoid saveElasticPipeline(@NotNull
ElasticAgentDefinition pipelineDefinition)
PipelineDefinitionpipelineDefinition - - Must not be nullvoid saveReturningElasticPipeline(@NotNull
ElasticAgentDefinition elasticDefinition)
PipelineDefinition of a returning elastic agent.elasticDefinition - returning elastic agent definitionLocalBuildAgent getLocalAgent(long pipelineId)
pipelineId - LocalBuildAgent object. Null if pipeline does not
exist@Nullable BuildAgent getAgent(long agentId)
@Nullable PipelineDefinition getAgentDefinition(@NotNull Long agentId)
Map<Long,PipelineDefinition> findAllAgentsForAgentIds(@NotNull Collection<Long> agentIds)
PipelineDefinitions keyed by their idagentIds - void disableAllAgents()
void enableAllAgents()
boolean checkPipelinesAreDisabled()
<T> T executeIfIdle(Callable<T> callable) throws Exception
Executes a given Callable only if no builds are in progress. Builds are
prevented from starting while the Callable executes.
callable - the Callable to be executedcallableBambooBusyException - if builds are in progressException - if thrown by callablevoid createLocalAgent(LocalAgentDefinition pipelineDefinition) throws BambooLicenseException
pipelineDefinition - BambooLicenseExceptionvoid removeAgent(long agentId)
throws TimeoutException
agentId - TimeoutExceptionboolean allowNewRemoteAgent()
boolean allowNewRemoteAgents(int numAgentsToCreate)
boolean allowNewElasticAgent()
boolean allowNewElasticAgents(int numOfAgentsToCreate)
boolean allowNewLocalAgent()
void stopAgent(@NotNull
BuildAgent agent)
agent - to be stoppedvoid onAgentReturning(@NotNull
BuildAgent agent)
agent - to be stoppedList<PipelineDefinition> getAllPersistedAgentDefinitions()
void abandonBuild(@NotNull
BuildAgent remoteAgent,
boolean agentStartingUp)
@Nullable PipelineDefinition getAgentDefinitionByName(@NotNull String name)
name - of the agent to find@NotNull List<PipelineDefinition> getAgentDefinitionsWithNameLike(@NotNull String likeName)
likeName - the string to matchvoid saveAnyPipeline(@NotNull
PipelineDefinition pipelineDefinition)
PipelineDefinition of any type (elastic, local, remote)
AgentConfigurationUpdateEvent is fired after the pipeline is savedpipelineDefinition - - Must not be nullvoid saveAnyPipeline(@NotNull
PipelineDefinition pipelineDefinition,
@Nullable
AgentConfigurationUpdatedEventFactory eventFactory)
PipelineDefinition of any type (elastic, local,
remote)pipelineDefinition - Must not be nulleventFactory - event factory used to create event sent after the pipeline is savedboolean updateAgentStatusIfResultReturnPossibleAfterServerRestart(long agentId,
ResultKey resultKey,
String displayName,
long deploymentResultId)
Copyright © 2021 Atlassian Software Systems Pty Ltd. All rights reserved.