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 booleancanRunInPool(int agentPoolId)intcompareTo(BuildTypeDescriptor o)Stringdescribe(boolean verbose)CompatibilityResultgetAgentCompatibility(AgentDescription agentDescription)Fetches compatibility information for given agent descriptionSAgentRestrictorgetAgentRestrictor()SBuildAgentgetBuildAgent()IntegergetBuildAgentId()BuildConfigurationInfogetBuildConfiguration()BuildEstimatesgetBuildEstimates()Returns a BuildEstimates object describing the estimated values of the pending build.BuildPromotionExgetBuildPromotion()Returns build promotionBuildPromotionInfogetBuildPromotionInfo()Returns build promotion, associated with this queued buildSBuildTypegetBuildType()BuildTypeExgetBuildTypeEx()StringgetBuildTypeId()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.CheckoutTypegetCheckoutType()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 buildStringgetDescription()Returns configuration description.StringgetExternalId()External id of this build configuration.StringgetFullName()Returns name in the form: <parent project name> / <parent project name> / ...StringgetItemId()Returns unique id of this item in build queue.StringgetLatestWaitReason()StringgetName()Returns presentable name.intgetOrderNumber()Returns order number of this build in the queue starting from 1StringgetProjectExternalId()Returns external id of the project this build configuration configured in.StringgetProjectId()Returns internal id of the project this build configuration configured in.StringgetProjectName()Returns project name this configuration belongs to.StringgetRequestor()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 configurationSBuildgetSequenceBuild()If associated build promotion has modification id, returns the sequence build which contains the same changes as this build promotion.TriggeredBygetTriggeredBy()Returns details about who and how added this build in queue.Map<String,Long>getWaitReasons()Returns current wait reasons for this queued build.DategetWhenQueued()Returns date when configuration has been added to the queue.booleanisCanBeReplacedByMergeOptimization()booleanisPaused()Returns if the configuration is paused.booleanisPersisted()booleanisPersonal()Returns if the triggered build is personal.booleanisStarted()Returns true if this build startedvoidmarkAsStarted()Called when a build started from this queued buildvoidmarkPersisted()voidremoveFailedToStartFromQueue()removes current build from queue without marking it as stated.voidremoveFromQueue(User user, String comment)Removes this queued build from the build queueRunningBuildExstartBuild(String requestor)Start build.voidstartChangesCollecting()voidterminate(boolean isCanceled, String comment, BuildProblemData buildProblemData)Removes current build from queue and creates a history build entry for it.StringtoString()booleantryLockBuildStarting()Should be called when build starts.voidunlockBuildStarting()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:
getBuildTypein interfaceSQueuedBuild- Returns:
- build configuration object.
-
getCanRunOnAgents
@NotNull public List<SBuildAgent> getCanRunOnAgents()
Description copied from interface:SQueuedBuildReturns agents this build can run on- Specified by:
getCanRunOnAgentsin interfaceSQueuedBuild- Returns:
- agents this build can run on
-
getCanRunOnAgentTypes
@NotNull public List<StartableAgentType> getCanRunOnAgentTypes()
- Specified by:
getCanRunOnAgentTypesin interfaceQueuedBuildEx- Returns:
- available cloud agent types where this build can be started
-
getCanRunOnAgents
@NotNull public List<SBuildAgent> getCanRunOnAgents(@NotNull List<SBuildAgent> availableAgents)
- Specified by:
getCanRunOnAgentsin interfaceQueuedBuildEx- Returns:
- accepts collection of agents and returns those where this queued build can run
-
canRunInPool
public boolean canRunInPool(int agentPoolId)
- Specified by:
canRunInPoolin interfaceQueuedBuildEx
-
getCompatibleAgents
@NotNull public Collection<SBuildAgent> getCompatibleAgents(@NotNull Collection<SBuildAgent> availableAgents)
Description copied from interface:QueuedBuildInfoTakes collection of agents as an argument and returns those which are compatible with current queued build- Specified by:
getCompatibleAgentsin interfaceQueuedBuildInfo- Parameters:
availableAgents- collection of agents- Returns:
- see above
-
getCompatibilityMap
@NotNull public Map<SBuildAgent,CompatibilityResult> getCompatibilityMap()
Description copied from interface:CompatibleAgentsReturns compatibility map, key is an agent and value is compatibility result.- Specified by:
getCompatibilityMapin interfaceCompatibleAgents- Specified by:
getCompatibilityMapin interfaceSQueuedBuild- Returns:
- compatible agents map
-
getCompatibleAgents
@NotNull public Collection<SBuildAgent> getCompatibleAgents()
Description copied from interface:CompatibleAgentsReturns collection of compatible agents- Specified by:
getCompatibleAgentsin interfaceCompatibleAgents- Returns:
- see above
-
getAgentCompatibility
@NotNull public CompatibilityResult getAgentCompatibility(@NotNull AgentDescription agentDescription)
Description copied from interface:CompatibleAgentsFetches compatibility information for given agent description- Specified by:
getAgentCompatibilityin 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:
getBuildAgentin interfaceQueuedBuildEx- Specified by:
getBuildAgentin interfaceSQueuedBuild- Returns:
- build agent to run build on or null
-
getBuildPromotionInfo
@NotNull public BuildPromotionInfo getBuildPromotionInfo()
Description copied from interface:QueuedBuildInfoReturns build promotion, associated with this queued build- Specified by:
getBuildPromotionInfoin interfaceQueuedBuildInfo
-
getBuildPromotion
@NotNull public BuildPromotionEx getBuildPromotion()
Description copied from interface:BuildPromotionOwnerReturns build promotion- Specified by:
getBuildPromotionin interfaceBuildPromotionOwner- Specified by:
getBuildPromotionin interfaceQueuedBuildEx- Returns:
- see above.
-
tryLockBuildStarting
public boolean tryLockBuildStarting()
Description copied from interface:QueuedBuildExShould 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:
tryLockBuildStartingin interfaceQueuedBuildEx- Returns:
-
startChangesCollecting
public void startChangesCollecting()
- Specified by:
startChangesCollectingin interfaceQueuedBuildEx
-
unlockBuildStarting
public void unlockBuildStarting()
Description copied from interface:QueuedBuildExUndoes start of a build, new build can be started from this queued build after that.- Specified by:
unlockBuildStartingin interfaceQueuedBuildEx
-
getBuildTypeEx
@NotNull public BuildTypeEx getBuildTypeEx() throws BuildTypeNotFoundException
- Specified by:
getBuildTypeExin interfaceQueuedBuildEx- Throws:
BuildTypeNotFoundException
-
isPersisted
public boolean isPersisted()
- Specified by:
isPersistedin interfaceQueuedBuildEx
-
markPersisted
public void markPersisted()
- Specified by:
markPersistedin interfaceQueuedBuildEx
-
getBuildConfiguration
@NotNull public BuildConfigurationInfo getBuildConfiguration()
- Specified by:
getBuildConfigurationin 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:
getBuildAgentIdin interfaceQueuedBuild- Specified by:
getBuildAgentIdin interfaceQueuedBuildInfo- Returns:
- build agent id to run build on or null
-
getAgentRestrictor
@Nullable public SAgentRestrictor getAgentRestrictor()
- Specified by:
getAgentRestrictorin interfaceQueuedBuild- Specified by:
getAgentRestrictorin interfaceQueuedBuildEx- Specified by:
getAgentRestrictorin 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:QueuedBuildReturns date when configuration has been added to the queue.- Specified by:
getWhenQueuedin interfaceQueuedBuild- Returns:
- date when configuration has been added to the queue.
-
getItemId
@NotNull public String getItemId()
Description copied from interface:QueuedBuildReturns unique id of this item in build queue.- Specified by:
getItemIdin interfaceQueuedBuild- Specified by:
getItemIdin interfaceQueuedBuildInfo- Returns:
- id of this item.
-
getRequestor
@NotNull public String getRequestor()
Description copied from interface:SQueuedBuildReturns 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:
getRequestorin interfaceSQueuedBuild- Returns:
- string requestor.
-
getTriggeredBy
public TriggeredBy getTriggeredBy()
Description copied from interface:SQueuedBuildReturns details about who and how added this build in queue.- Specified by:
getTriggeredByin interfaceSQueuedBuild- Returns:
- see above
-
getName
@NotNull public String getName()
Description copied from interface:BuildTypeDescriptorReturns presentable name. Can be changed by the user.- Specified by:
getNamein interfaceBuildTypeDescriptor- Returns:
- presentable name
-
getFullName
public String getFullName()
Description copied from interface:BuildTypeDescriptorReturns name in the form: <parent project name> / <parent project name> / ... / <project name> / <build type name>- Specified by:
getFullNamein interfaceBuildTypeDescriptor- Returns:
- see above
-
getDescription
public String getDescription()
Description copied from interface:BuildTypeDescriptorReturns configuration description.- Specified by:
getDescriptionin interfaceBuildTypeDescriptor- Returns:
- configuration description.
-
getProjectName
@NotNull public String getProjectName()
Description copied from interface:BuildTypeDescriptorReturns project name this configuration belongs to.- Specified by:
getProjectNamein interfaceBuildTypeDescriptor- Returns:
- parent project name.
-
getRunnerTypes
public Collection<String> getRunnerTypes()
Description copied from interface:BuildTypeDescriptorReturns collection of types of enabled build runners configured in this configuration- Specified by:
getRunnerTypesin interfaceBuildTypeDescriptor- Returns:
- see above
-
getBuildTypeId
@NotNull public String getBuildTypeId()
Description copied from interface:QueuedBuildReturns corresponding build configuration internal id. For personal builds, returns configurationId for the personal build.- Specified by:
getBuildTypeIdin interfaceBuildTypeDescriptor- Specified by:
getBuildTypeIdin interfaceQueuedBuild- Returns:
- corresponding build configuration internal id.
-
getExternalId
@NotNull public String getExternalId()
Description copied from interface:BuildTypeDescriptorExternal id of this build configuration. This identifier is unique in all build configurations and build templates scope.- Specified by:
getExternalIdin interfaceBuildTypeDescriptor- Returns:
- the external identifier of this build configuration.
-
isPersonal
public boolean isPersonal()
Description copied from interface:QueuedBuildReturns if the triggered build is personal.- Specified by:
isPersonalin interfaceBuildTypeDescriptor- Specified by:
isPersonalin interfaceQueuedBuild- Returns:
- if the triggered build is personal.
-
getOrderNumber
public int getOrderNumber()
Description copied from interface:QueuedBuildReturns order number of this build in the queue starting from 1- Specified by:
getOrderNumberin interfaceQueuedBuild- Returns:
- order number of this build
-
getCheckoutType
public BuildTypeDescriptor.CheckoutType getCheckoutType()
Description copied from interface:BuildTypeDescriptorReturns 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:
getCheckoutTypein interfaceBuildTypeDescriptor- Returns:
- method to get sources on agent.
-
isPaused
public boolean isPaused()
Description copied from interface:BuildTypeDescriptorReturns if the configuration is paused.- Specified by:
isPausedin 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:BuildTypeDescriptorReturns internal id of the project this build configuration configured in.- Specified by:
getProjectIdin interfaceBuildTypeDescriptor- Returns:
- parent project internal id.
-
getProjectExternalId
@NotNull public String getProjectExternalId()
Description copied from interface:BuildTypeDescriptorReturns external id of the project this build configuration configured in.- Specified by:
getProjectExternalIdin interfaceBuildTypeDescriptor- Returns:
- parent project external id.
-
compareTo
public int compareTo(BuildTypeDescriptor o)
- Specified by:
compareToin interfaceComparable<BuildTypeDescriptor>
-
getBuildEstimates
@Nullable public BuildEstimates getBuildEstimates()
Description copied from interface:SQueuedBuildReturns 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:
getBuildEstimatesin 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:SQueuedBuildRemoves this queued build from the build queue- Specified by:
removeFromQueuein interfaceSQueuedBuild- Parameters:
user- user who initiated removecomment- comment
-
markAsStarted
public void markAsStarted()
Description copied from interface:QueuedBuildExCalled when a build started from this queued build- Specified by:
markAsStartedin interfaceQueuedBuildEx
-
removeFailedToStartFromQueue
public void removeFailedToStartFromQueue()
Description copied from interface:QueuedBuildExremoves current build from queue without marking it as stated.- Specified by:
removeFailedToStartFromQueuein interfaceQueuedBuildEx
-
terminate
public void terminate(boolean isCanceled, @Nullable String comment, @NotNull BuildProblemData buildProblemData)Description copied from interface:QueuedBuildExRemoves current build from queue and creates a history build entry for it.- Specified by:
terminatein 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:QueuedBuildExReturns true if this build started- Specified by:
isStartedin interfaceQueuedBuildEx- Returns:
- true if this build started
-
getSequenceBuild
@Nullable public SBuild getSequenceBuild()
Description copied from interface:BuildPromotionOwnerIf 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:
getSequenceBuildin 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:
isCanBeReplacedByMergeOptimizationin 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:QueuedBuildExStart build. The method can be used to start build wihtout agent.- Specified by:
startBuildin interfaceQueuedBuildEx- Parameters:
requestor- build requestor information like name or so
-
getWaitReasons
@NotNull public Map<String,Long> getWaitReasons()
Description copied from interface:QueuedBuildExReturns 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:
getWaitReasonsin 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:
getLatestWaitReasonin interfaceQueuedBuildEx- Returns:
- the latest wait reason which prevented this build from starting.
-
-