Package jetbrains.buildServer.serverSide
Interface BuildQueueEx
-
- All Superinterfaces:
BatchTrigger
,BuildQueue
- All Known Implementing Classes:
BuildQueueImpl
,SecuredBuildQueue
public interface BuildQueueEx extends BuildQueue, BatchTrigger
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description List<QueuedBuildEx>
addToQueue(Map<BuildPromotionEx,SAgentRestrictor> promoAgentRestrictorMap, String rawTriggeredBy)
Adds promotions to the queue with corresponding agent restrictors (if agent restrictor is null then no agent restrictor is used).void
cancelMatchedItems(Filter<SQueuedBuild> itemsFilter, SUser user, String comment)
Removes and cancels items matched by the specified filter.List<SQueuedBuild>
findPersonalBuildsByPersonalChangeListId(long personalChangeListId)
QueuedBuildEx
findQueued(String itemId)
Searches for an item in queue with specified item id.QueuedBuildEx
findQueued(String buildTypeId, Integer agentId)
Looks for build configuration with specified id scheduled to run on specified agent in the queue.QueuedBuildEx
findQueued(BuildPromotion promotion)
Searches for a queued build item for the specified promotionList<SQueuedBuild>
getItemsByPool(int agentPoolId)
Returns all items currently waiting in queue corresponding to the specified agent pool.List<QueuedBuildEx>
getItemsEx()
int
getNumberOfItemsByPool(int agentPoolId)
Returns number of items currently waiting in queue corresponding to the specified agent pool.int
getOrderNumber(SQueuedBuild queuedBuild)
Returns order number of the specified queued buildList<QueuedBuildEx>
getPersistedItemsEx()
boolean
mergeBuilds(Predicate<SQueuedBuild> queuedBuildsFilter)
Optimizes build queue by removing builds which can be safely substituted by newer builds added to the queue.void
moveDependenciesToTop(BuildPromotion promotion)
Moves dependencies of given promotion to the top of the queueboolean
optimizeChains(List<BuildPromotionEx> buildPromotions)
Optimizes build chains, i.e.void
removeAllFromQueue()
Removes all items from the queuevoid
removeAllFromQueue(String buildTypeId)
Removes all items from the queue which correspond to specified build configuration.void
removeAllFromQueue(String buildTypeId, SUser user, String comment)
Removes all items from the queue which correspond to specified build configuration.void
removeMatchedItems(Filter<SQueuedBuild> itemsFilter, SUser user, String comment)
Removes items matched by the specified filter from the queueList<QueuedBuildEx>
restoreInQueue(BuildPromotionEx promo, SAgentRestrictor agentRestrictor, String rawTriggeredBy)
Re-adds build into the queue.void
scheduleBuildQueueReload()
Sends event to reload queue from database (for debug API, TW-85394)void
scheduleCheckingForChangesForQueuedBuilds(Collection<QueuedBuildEx> queuedBuilds)
Processes the specified collection of queued builds, finds builds where changes collection should be done and schedules it.void
setOrderingStrategy(BuildQueueOrderingStrategy strategy)
Assign ordering strategy for this build queueboolean
shouldCollectChangesInQueue(BuildPromotionEx promotion)
Returnstrue
if changes should be collected for specified promotion while it is in build queuevoid
terminateQueuedBuild(SQueuedBuild queuedBuild, SUser user, boolean isCanceled, String comment, BuildProblemData buildProblemData)
Removes specified queued build from the queue and creates a history build entry for it.-
Methods inherited from interface jetbrains.buildServer.serverSide.BatchTrigger
newTriggerTask, processTasks
-
Methods inherited from interface jetbrains.buildServer.serverSide.BuildQueue
applyOrder, getFirst, getItems, getItems, getLast, getNumberOfItems, isInQueue, isQueueEmpty, moveBottom, moveTop, removeItems, removeQueuedBuilds
-
-
-
-
Method Detail
-
addToQueue
@NotNull List<QueuedBuildEx> addToQueue(@NotNull Map<BuildPromotionEx,SAgentRestrictor> promoAgentRestrictorMap, @NotNull String rawTriggeredBy)
Adds promotions to the queue with corresponding agent restrictors (if agent restrictor is null then no agent restrictor is used). If same build is already in queue then new build is not added. If promotion has associated graph then it must be top of this graph. All nodes of the graph will be added in the queue. If chains passed to this method intersects in personal build nodes then only one personal build will be added in queue for each intersection. Returns newly added builds and currently queued builds for not added builds.- Parameters:
promoAgentRestrictorMap
- map of top promotion to agent restrictorsrawTriggeredBy
- triggered by- Returns:
- see above
- Throws:
BuildTypeNotFoundException
- if promotion build configuration does not exist
-
removeAllFromQueue
void removeAllFromQueue(String buildTypeId)
Removes all items from the queue which correspond to specified build configuration.- Parameters:
buildTypeId
- id of build configuration
-
removeAllFromQueue
void removeAllFromQueue()
Removes all items from the queue
-
removeAllFromQueue
void removeAllFromQueue(String buildTypeId, SUser user, String comment)
Removes all items from the queue which correspond to specified build configuration.- Parameters:
buildTypeId
- id of build configurationuser
- usercomment
- comment
-
removeMatchedItems
void removeMatchedItems(@NotNull Filter<SQueuedBuild> itemsFilter, @Nullable SUser user, @Nullable String comment)
Removes items matched by the specified filter from the queue- Parameters:
itemsFilter
- queue items filteruser
- user who performs operation, if user is not null then build will be cancelled, otherwise it can be completely removed if there are no started builds depending on itcomment
- comment to use for remove operation- Since:
- 2018.2.2
-
cancelMatchedItems
void cancelMatchedItems(@NotNull Filter<SQueuedBuild> itemsFilter, @Nullable SUser user, @Nullable String comment)
Removes and cancels items matched by the specified filter. The main difference of this method andremoveMatchedItems(Filter, SUser, String)
is that this method always creates cancelled builds in history for removed queued items, while removeMatchedItems can skip creating cancelled builds if user is not specified- Parameters:
itemsFilter
- queue items filteruser
- user who performs operationcomment
- comment to use for remove operation- Since:
- 2018.2.2
-
terminateQueuedBuild
void terminateQueuedBuild(@NotNull SQueuedBuild queuedBuild, @Nullable SUser user, boolean isCanceled, @Nullable String comment, @NotNull BuildProblemData buildProblemData)
Removes specified queued build from the queue and creates a history build entry for it.- Parameters:
queuedBuild
- a queued build to terminateuser
- user who performs operationisCanceled
- 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- Throws:
IllegalArgumentException
- in case 'isCanceled' is false and 'buildProblemData' type is not an internal error (seeErrorData.isInternalError(String)
)- Since:
- 2023.11.1
-
getOrderNumber
int getOrderNumber(@NotNull SQueuedBuild queuedBuild)
Returns order number of the specified queued build- Parameters:
queuedBuild
- queued build- Returns:
- order number or 0 if specified queued build does not exist
-
findPersonalBuildsByPersonalChangeListId
List<SQueuedBuild> findPersonalBuildsByPersonalChangeListId(long personalChangeListId)
-
mergeBuilds
boolean mergeBuilds(@Nullable Predicate<SQueuedBuild> queuedBuildsFilter)
Optimizes build queue by removing builds which can be safely substituted by newer builds added to the queue.- Parameters:
queuedBuildsFilter
- filter to apply to the queue builds, if the filter returns false then the queued build won't participate in the optimization, if null then all currently queued builds will be optimized- Returns:
- true if queue was changed and false otherwise
-
optimizeChains
boolean optimizeChains(@NotNull List<BuildPromotionEx> buildPromotions)
Optimizes build chains, i.e. reassigns builds to started builds if possible. If during optimization some of the build promotions are removed from the chains, their queued builds will be removed from the queue as well.- Parameters:
buildPromotions
- build promotions to optimize- Returns:
- true if at least one build was removed from the queue as a result of optimization
-
restoreInQueue
List<QueuedBuildEx> restoreInQueue(@NotNull BuildPromotionEx promo, @Nullable SAgentRestrictor agentRestrictor, @NotNull String rawTriggeredBy)
Re-adds build into the queue. A copy of specified build promotion will be created, if there were snapshot dependencies on the original build they will be moved to the new one.- Parameters:
promo
- original promoagentRestrictor
- agent restrictorrawTriggeredBy
- triggered by- Returns:
- newly added queued builds
-
setOrderingStrategy
void setOrderingStrategy(@NotNull BuildQueueOrderingStrategy strategy)
Assign ordering strategy for this build queue- Parameters:
strategy
- new ordering strategy
-
getItemsEx
@NotNull List<QueuedBuildEx> getItemsEx()
-
getPersistedItemsEx
@NotNull List<QueuedBuildEx> getPersistedItemsEx()
-
getItemsByPool
@NotNull List<SQueuedBuild> getItemsByPool(int agentPoolId)
Returns all items currently waiting in queue corresponding to the specified agent pool.- Parameters:
agentPoolId
- agent pool id- Returns:
- see above
-
getNumberOfItemsByPool
int getNumberOfItemsByPool(int agentPoolId)
Returns number of items currently waiting in queue corresponding to the specified agent pool.- Returns:
- number of items currently waiting in queue corresponding to the specified agent pool.
-
scheduleCheckingForChangesForQueuedBuilds
void scheduleCheckingForChangesForQueuedBuilds(@NotNull Collection<QueuedBuildEx> queuedBuilds)
Processes the specified collection of queued builds, finds builds where changes collection should be done and schedules it.- Since:
- 2018.2
-
shouldCollectChangesInQueue
boolean shouldCollectChangesInQueue(@NotNull BuildPromotionEx promotion)
Returnstrue
if changes should be collected for specified promotion while it is in build queue- Parameters:
promotion
- build promotion of interest- Returns:
- see above
-
findQueued
@Nullable QueuedBuildEx findQueued(@NotNull BuildPromotion promotion)
Searches for a queued build item for the specified promotion- Returns:
- found item or null
-
findQueued
@Nullable QueuedBuildEx findQueued(@NotNull String buildTypeId, @Nullable Integer agentId)
Description copied from interface:BuildQueue
Looks for build configuration with specified id scheduled to run on specified agent in the queue.- Specified by:
findQueued
in interfaceBuildQueue
- Parameters:
buildTypeId
- id of build configuration to search foragentId
- id of the agent. If not null only build configuration scheduled to specified agent will be returned. If null then build configuration which is not scheduled to any specific agent is returned.- Returns:
- found item or null
-
findQueued
@Nullable QueuedBuildEx findQueued(@NotNull String itemId)
Description copied from interface:BuildQueue
Searches for an item in queue with specified item id.- Specified by:
findQueued
in interfaceBuildQueue
- Parameters:
itemId
- id of the item to look for.- Returns:
- found item or null
-
moveDependenciesToTop
void moveDependenciesToTop(@NotNull BuildPromotion promotion)
Moves dependencies of given promotion to the top of the queue- Parameters:
promotion
- build promotion
-
scheduleBuildQueueReload
void scheduleBuildQueueReload()
Sends event to reload queue from database (for debug API, TW-85394)
-
-