Class QueuedBuildImpl
- java.lang.Object
-
- jetbrains.buildServer.serverSide.impl.QueuedBuildImpl
-
- All Implemented Interfaces:
Comparable<BuildTypeDescriptor>
,BuildTypeDescriptor
,Loggable
,QueuedBuild
,QueuedBuildInfo
,BuildPromotionOwner
,CompatibleAgents
,QueuedBuildEx
,SQueuedBuild
- Direct Known Subclasses:
SecuredQueuedBuild
public class QueuedBuildImpl extends Object implements QueuedBuildEx
- Author:
- Kir
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jetbrains.buildServer.BuildTypeDescriptor
BuildTypeDescriptor.CheckoutType
-
-
Field Summary
-
Fields inherited from interface jetbrains.buildServer.BuildTypeDescriptor
FULL_NAME_SEPARATOR
-
-
Constructor Summary
Constructors Constructor Description QueuedBuildImpl(BuildPromotion buildPromotion, SAgentRestrictor agentRestrictor, String rawTriggeredBy, BuildEstimator buildEstimator, BuildQueueEx buildQueue, BuildAgentManager agentManager, AgentPoolManager agentPoolManager, BuildAgentFactory agentFactory, BuildServerEx server, TriggeredByParser triggeredByParser, WaitReasonStatisticsCollector waitReasonStatisticsCollector, CanRunOnAgentsCalculator canRunOnCalculator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canRunInPool(int agentPoolId)
int
compareTo(BuildTypeDescriptor o)
String
describe(boolean verbose)
CompatibilityResult
getAgentCompatibility(AgentDescription agentDescription)
Fetches compatibility information for given agent descriptionSAgentRestrictor
getAgentRestrictor()
SBuildAgent
getBuildAgent()
Integer
getBuildAgentId()
BuildConfigurationInfo
getBuildConfiguration()
BuildEstimates
getBuildEstimates()
Returns a BuildEstimates object describing the estimated values of the pending build.BuildPromotionEx
getBuildPromotion()
Returns build promotionBuildPromotionInfo
getBuildPromotionInfo()
Returns build promotion, associated with this queued buildSBuildType
getBuildType()
BuildTypeEx
getBuildTypeEx()
String
getBuildTypeId()
Returns corresponding build configuration internal id.List<SBuildAgent>
getCanRunOnAgents()
Returns agents this build can run onList<SBuildAgent>
getCanRunOnAgents(List<SBuildAgent> availableAgents)
List<StartableAgentType>
getCanRunOnAgentTypes()
BuildTypeDescriptor.CheckoutType
getCheckoutType()
Returns method used by agent to retrieve project sources.Map<SBuildAgent,CompatibilityResult>
getCompatibilityMap()
Returns compatibility map, key is an agent and value is compatibility result.Collection<SBuildAgent>
getCompatibleAgents()
Returns collection of compatible agentsCollection<SBuildAgent>
getCompatibleAgents(Collection<SBuildAgent> availableAgents)
Takes collection of agents as an argument and returns those which are compatible with current queued buildString
getDescription()
Returns configuration description.String
getExternalId()
External id of this build configuration.String
getFullName()
Returns name in the form: <parent project name> / <parent project name> / ...String
getItemId()
Returns unique id of this item in build queue.String
getLatestWaitReason()
String
getName()
Returns presentable name.int
getOrderNumber()
Returns order number of this build in the queue starting from 1String
getProjectExternalId()
Returns external id of the project this build configuration configured in.String
getProjectId()
Returns internal id of the project this build configuration configured in.String
getProjectName()
Returns project name this configuration belongs to.String
getRequestor()
Returns the reason, why configuration has been queued (for example, it might be trigger name, if configuration was triggered, of user name, it it was added to queue manually).Collection<String>
getRunnerTypes()
Returns collection of types of enabled build runners configured in this configurationSBuild
getSequenceBuild()
If associated build promotion has modification id, returns the sequence build which contains the same changes as this build promotion.TriggeredBy
getTriggeredBy()
Returns details about who and how added this build in queue.Map<String,Long>
getWaitReasons()
Returns current wait reasons for this queued build.Date
getWhenQueued()
Returns date when configuration has been added to the queue.boolean
isCanBeReplacedByMergeOptimization()
boolean
isPaused()
Returns if the configuration is paused.boolean
isPersisted()
boolean
isPersonal()
Returns if the triggered build is personal.boolean
isStarted()
Returns true if this build startedvoid
markAsStarted()
Called when a build started from this queued buildvoid
markPersisted()
void
removeFailedToStartFromQueue()
removes current build from queue without marking it as stated.void
removeFromQueue(User user, String comment)
Removes this queued build from the build queueRunningBuildEx
startBuild(String requestor)
Start build.void
startChangesCollecting()
void
terminate(boolean isCanceled, String comment, BuildProblemData buildProblemData)
Removes current build from queue and creates a history build entry for it.String
toString()
boolean
tryLockBuildStarting()
Should be called when build starts.void
unlockBuildStarting()
Undoes start of a build, new build can be started from this queued build after that.
-
-
-
Constructor Detail
-
QueuedBuildImpl
public QueuedBuildImpl(@NotNull BuildPromotion buildPromotion, @Nullable SAgentRestrictor agentRestrictor, @NotNull String rawTriggeredBy, @NotNull BuildEstimator buildEstimator, @NotNull BuildQueueEx buildQueue, @NotNull BuildAgentManager agentManager, @NotNull AgentPoolManager agentPoolManager, @NotNull BuildAgentFactory agentFactory, @NotNull BuildServerEx server, @NotNull TriggeredByParser triggeredByParser, @NotNull WaitReasonStatisticsCollector waitReasonStatisticsCollector, @NotNull CanRunOnAgentsCalculator canRunOnCalculator)
-
-
Method Detail
-
getBuildType
@NotNull public SBuildType getBuildType()
- Specified by:
getBuildType
in interfaceSQueuedBuild
- Returns:
- build configuration object.
-
getCanRunOnAgents
@NotNull public List<SBuildAgent> getCanRunOnAgents()
Description copied from interface:SQueuedBuild
Returns agents this build can run on- Specified by:
getCanRunOnAgents
in interfaceSQueuedBuild
- Returns:
- agents this build can run on
-
getCanRunOnAgentTypes
@NotNull public List<StartableAgentType> getCanRunOnAgentTypes()
- Specified by:
getCanRunOnAgentTypes
in interfaceQueuedBuildEx
- Returns:
- available cloud agent types where this build can be started
-
getCanRunOnAgents
@NotNull public List<SBuildAgent> getCanRunOnAgents(@NotNull List<SBuildAgent> availableAgents)
- Specified by:
getCanRunOnAgents
in interfaceQueuedBuildEx
- Returns:
- accepts collection of agents and returns those where this queued build can run
-
canRunInPool
public boolean canRunInPool(int agentPoolId)
- Specified by:
canRunInPool
in interfaceQueuedBuildEx
-
getCompatibleAgents
@NotNull public Collection<SBuildAgent> getCompatibleAgents(@NotNull Collection<SBuildAgent> availableAgents)
Description copied from interface:QueuedBuildInfo
Takes collection of agents as an argument and returns those which are compatible with current queued build- Specified by:
getCompatibleAgents
in interfaceQueuedBuildInfo
- Parameters:
availableAgents
- collection of agents- Returns:
- see above
-
getCompatibilityMap
@NotNull public Map<SBuildAgent,CompatibilityResult> getCompatibilityMap()
Description copied from interface:CompatibleAgents
Returns compatibility map, key is an agent and value is compatibility result.- Specified by:
getCompatibilityMap
in interfaceCompatibleAgents
- Specified by:
getCompatibilityMap
in interfaceSQueuedBuild
- Returns:
- compatible agents map
-
getCompatibleAgents
@NotNull public Collection<SBuildAgent> getCompatibleAgents()
Description copied from interface:CompatibleAgents
Returns collection of compatible agents- Specified by:
getCompatibleAgents
in interfaceCompatibleAgents
- Returns:
- see above
-
getAgentCompatibility
@NotNull public CompatibilityResult getAgentCompatibility(@NotNull AgentDescription agentDescription)
Description copied from interface:CompatibleAgents
Fetches compatibility information for given agent description- Specified by:
getAgentCompatibility
in interfaceCompatibleAgents
- Parameters:
agentDescription
- agent description- Returns:
- compatibility results.
- See Also:
CompatibilityResult
-
describe
@NotNull public String describe(boolean verbose)
-
getBuildAgent
@Nullable public SBuildAgent getBuildAgent()
- Specified by:
getBuildAgent
in interfaceQueuedBuildEx
- Specified by:
getBuildAgent
in interfaceSQueuedBuild
- Returns:
- build agent to run build on or null
-
getBuildPromotionInfo
@NotNull public BuildPromotionInfo getBuildPromotionInfo()
Description copied from interface:QueuedBuildInfo
Returns build promotion, associated with this queued build- Specified by:
getBuildPromotionInfo
in interfaceQueuedBuildInfo
-
getBuildPromotion
@NotNull public BuildPromotionEx getBuildPromotion()
Description copied from interface:BuildPromotionOwner
Returns build promotion- Specified by:
getBuildPromotion
in interfaceBuildPromotionOwner
- Specified by:
getBuildPromotion
in interfaceQueuedBuildEx
- Returns:
- see above.
-
tryLockBuildStarting
public boolean tryLockBuildStarting()
Description copied from interface:QueuedBuildEx
Should be called when build starts. Returns true if build can be started or false if there is a build starting from this queued build.- Specified by:
tryLockBuildStarting
in interfaceQueuedBuildEx
- Returns:
-
startChangesCollecting
public void startChangesCollecting()
- Specified by:
startChangesCollecting
in interfaceQueuedBuildEx
-
unlockBuildStarting
public void unlockBuildStarting()
Description copied from interface:QueuedBuildEx
Undoes start of a build, new build can be started from this queued build after that.- Specified by:
unlockBuildStarting
in interfaceQueuedBuildEx
-
getBuildTypeEx
@NotNull public BuildTypeEx getBuildTypeEx() throws BuildTypeNotFoundException
- Specified by:
getBuildTypeEx
in interfaceQueuedBuildEx
- Throws:
BuildTypeNotFoundException
-
isPersisted
public boolean isPersisted()
- Specified by:
isPersisted
in interfaceQueuedBuildEx
-
markPersisted
public void markPersisted()
- Specified by:
markPersisted
in interfaceQueuedBuildEx
-
getBuildConfiguration
@NotNull public BuildConfigurationInfo getBuildConfiguration()
- Specified by:
getBuildConfiguration
in interfaceQueuedBuildInfo
- Returns:
- configuration specific information related to this build. since 9.1: if build configuration does not exist, returns null object.
-
getBuildAgentId
@Nullable public Integer getBuildAgentId()
- Specified by:
getBuildAgentId
in interfaceQueuedBuild
- Specified by:
getBuildAgentId
in interfaceQueuedBuildInfo
- Returns:
- build agent id to run build on or null
-
getAgentRestrictor
@Nullable public SAgentRestrictor getAgentRestrictor()
- Specified by:
getAgentRestrictor
in interfaceQueuedBuild
- Specified by:
getAgentRestrictor
in interfaceQueuedBuildEx
- Specified by:
getAgentRestrictor
in interfaceQueuedBuildInfo
- Returns:
- agent restrictor if the build is assigned to a specific set of agents, null otherwise.
-
getWhenQueued
@NotNull public Date getWhenQueued()
Description copied from interface:QueuedBuild
Returns date when configuration has been added to the queue.- Specified by:
getWhenQueued
in interfaceQueuedBuild
- Returns:
- date when configuration has been added to the queue.
-
getItemId
@NotNull public String getItemId()
Description copied from interface:QueuedBuild
Returns unique id of this item in build queue.- Specified by:
getItemId
in interfaceQueuedBuild
- Specified by:
getItemId
in interfaceQueuedBuildInfo
- Returns:
- id of this item.
-
getRequestor
@NotNull public String getRequestor()
Description copied from interface:SQueuedBuild
Returns the reason, why configuration has been queued (for example, it might be trigger name, if configuration was triggered, of user name, it it was added to queue manually).- Specified by:
getRequestor
in interfaceSQueuedBuild
- Returns:
- string requestor.
-
getTriggeredBy
public TriggeredBy getTriggeredBy()
Description copied from interface:SQueuedBuild
Returns details about who and how added this build in queue.- Specified by:
getTriggeredBy
in interfaceSQueuedBuild
- Returns:
- see above
-
getName
@NotNull public String getName()
Description copied from interface:BuildTypeDescriptor
Returns presentable name. Can be changed by the user.- Specified by:
getName
in interfaceBuildTypeDescriptor
- Returns:
- presentable name
-
getFullName
public String getFullName()
Description copied from interface:BuildTypeDescriptor
Returns name in the form: <parent project name> / <parent project name> / ... / <project name> / <build type name>- Specified by:
getFullName
in interfaceBuildTypeDescriptor
- Returns:
- see above
-
getDescription
public String getDescription()
Description copied from interface:BuildTypeDescriptor
Returns configuration description.- Specified by:
getDescription
in interfaceBuildTypeDescriptor
- Returns:
- configuration description.
-
getProjectName
@NotNull public String getProjectName()
Description copied from interface:BuildTypeDescriptor
Returns project name this configuration belongs to.- Specified by:
getProjectName
in interfaceBuildTypeDescriptor
- Returns:
- parent project name.
-
getRunnerTypes
public Collection<String> getRunnerTypes()
Description copied from interface:BuildTypeDescriptor
Returns collection of types of enabled build runners configured in this configuration- Specified by:
getRunnerTypes
in interfaceBuildTypeDescriptor
- Returns:
- see above
-
getBuildTypeId
@NotNull public String getBuildTypeId()
Description copied from interface:QueuedBuild
Returns corresponding build configuration internal id. For personal builds, returns configurationId for the personal build.- Specified by:
getBuildTypeId
in interfaceBuildTypeDescriptor
- Specified by:
getBuildTypeId
in interfaceQueuedBuild
- Returns:
- corresponding build configuration internal id.
-
getExternalId
@NotNull public String getExternalId()
Description copied from interface:BuildTypeDescriptor
External id of this build configuration. This identifier is unique in all build configurations and build templates scope.- Specified by:
getExternalId
in interfaceBuildTypeDescriptor
- Returns:
- the external identifier of this build configuration.
-
isPersonal
public boolean isPersonal()
Description copied from interface:QueuedBuild
Returns if the triggered build is personal.- Specified by:
isPersonal
in interfaceBuildTypeDescriptor
- Specified by:
isPersonal
in interfaceQueuedBuild
- Returns:
- if the triggered build is personal.
-
getOrderNumber
public int getOrderNumber()
Description copied from interface:QueuedBuild
Returns order number of this build in the queue starting from 1- Specified by:
getOrderNumber
in interfaceQueuedBuild
- Returns:
- order number of this build
-
getCheckoutType
public BuildTypeDescriptor.CheckoutType getCheckoutType()
Description copied from interface:BuildTypeDescriptor
Returns method used by agent to retrieve project sources. CheckoutType.ON_SERVER server creates patch and sends it to agent CheckoutType.ON_AGENT agent checks sources out CheckoutType.MANUAL script does it itself.- Specified by:
getCheckoutType
in interfaceBuildTypeDescriptor
- Returns:
- method to get sources on agent.
-
isPaused
public boolean isPaused()
Description copied from interface:BuildTypeDescriptor
Returns if the configuration is paused.- Specified by:
isPaused
in interfaceBuildTypeDescriptor
- Returns:
- true is build is paused. In this state build can be added to queue manually only, all other triggers are disabled.
-
getProjectId
@NotNull public String getProjectId()
Description copied from interface:BuildTypeDescriptor
Returns internal id of the project this build configuration configured in.- Specified by:
getProjectId
in interfaceBuildTypeDescriptor
- Returns:
- parent project internal id.
-
getProjectExternalId
@NotNull public String getProjectExternalId()
Description copied from interface:BuildTypeDescriptor
Returns external id of the project this build configuration configured in.- Specified by:
getProjectExternalId
in interfaceBuildTypeDescriptor
- Returns:
- parent project external id.
-
compareTo
public int compareTo(BuildTypeDescriptor o)
- Specified by:
compareTo
in interfaceComparable<BuildTypeDescriptor>
-
getBuildEstimates
@Nullable public BuildEstimates getBuildEstimates()
Description copied from interface:SQueuedBuild
Returns a BuildEstimates object describing the estimated values of the pending build. The returned time interval can be open, that is it doesn't contain the finish estimate (getEndPoint() returns null) in case of inability to estimate build duration. The time base for the time interval is the moment of invocation (with some accuracy).- Specified by:
getBuildEstimates
in interfaceSQueuedBuild
- Returns:
- null if the times cannot be estimated or the build isn't in the queue.
-
removeFromQueue
public void removeFromQueue(User user, String comment)
Description copied from interface:SQueuedBuild
Removes this queued build from the build queue- Specified by:
removeFromQueue
in interfaceSQueuedBuild
- Parameters:
user
- user who initiated removecomment
- comment
-
markAsStarted
public void markAsStarted()
Description copied from interface:QueuedBuildEx
Called when a build started from this queued build- Specified by:
markAsStarted
in interfaceQueuedBuildEx
-
removeFailedToStartFromQueue
public void removeFailedToStartFromQueue()
Description copied from interface:QueuedBuildEx
removes current build from queue without marking it as stated.- Specified by:
removeFailedToStartFromQueue
in interfaceQueuedBuildEx
-
terminate
public void terminate(boolean isCanceled, @Nullable String comment, @NotNull BuildProblemData buildProblemData)
Description copied from interface:QueuedBuildEx
Removes current build from queue and creates a history build entry for it.- Specified by:
terminate
in interfaceQueuedBuildEx
- Parameters:
isCanceled
- whether to create cancelation info for a history build entry. Status of the created build is also detrmined by this parameter: true->UNKNOWN, false->FAILURE.comment
- comment to use for logging during remove operation as well as cancellation info comment if 'isCanceled' is truebuildProblemData
- build problem to add to the history build
-
isStarted
public boolean isStarted()
Description copied from interface:QueuedBuildEx
Returns true if this build started- Specified by:
isStarted
in interfaceQueuedBuildEx
- Returns:
- true if this build started
-
getSequenceBuild
@Nullable public SBuild getSequenceBuild()
Description copied from interface:BuildPromotionOwner
If associated build promotion has modification id, returns the sequence build which contains the same changes as this build promotion. I.e. returns the first build, which contains all the changes from associated build promotion. If associated build promotion already in changes sequence, returnsBuildPromotion.getAssociatedBuild()
- Specified by:
getSequenceBuild
in interfaceBuildPromotionOwner
- Returns:
- sequence build for the same changes as for associated build promotion, or null if there are no such a build
-
isCanBeReplacedByMergeOptimization
public boolean isCanBeReplacedByMergeOptimization()
- Specified by:
isCanBeReplacedByMergeOptimization
in interfaceQueuedBuildEx
- Returns:
- true if this queued build can be optimized (removed from the queue by queue optimizer)
-
startBuild
@NotNull public RunningBuildEx startBuild(@NotNull String requestor)
Description copied from interface:QueuedBuildEx
Start build. The method can be used to start build wihtout agent.- Specified by:
startBuild
in interfaceQueuedBuildEx
- Parameters:
requestor
- build requestor information like name or so
-
getWaitReasons
@NotNull public Map<String,Long> getWaitReasons()
Description copied from interface:QueuedBuildEx
Returns current wait reasons for this queued build. The key of the map is a wait reason description in human friendly form. The value is amount of milliseconds this wait reason was reported for this queued build.- Specified by:
getWaitReasons
in interfaceQueuedBuildEx
- Returns:
- map of a wait reason to amount of time it was reported for the build in milliseconds
-
getLatestWaitReason
@Nullable public String getLatestWaitReason()
- Specified by:
getLatestWaitReason
in interfaceQueuedBuildEx
- Returns:
- the latest wait reason which prevented this build from starting.
-
-