in server/src/jetbrains/buildServer/sharedResources/server/SharedResourcesStartBuildPrecondition.java [227:258]
private WaitReason processSingleBuild(@NotNull final BuildPromotionEx buildPromotion,
@NotNull final DistributionDataAccessor accessor,
@NotNull final Supplier<Map<Resource, TakenLock>> takenLocksSupplier,
@NotNull final BuildPromotion promotion,
final boolean emulationMode) {
final String projectId = buildPromotion.getProjectId();
final SBuildType buildType = buildPromotion.getBuildType();
WaitReason reason = null;
if (buildType != null && projectId != null) {
final Collection<SharedResourcesFeature> features = myFeatures.searchForFeatures(buildPromotion);
if (!features.isEmpty()) {
reason = checkForInvalidLocks(buildPromotion);
if (reason == null) {
// Collection<Lock> ---> Collection<ResolvedLock> (i.e. lock against resolved resource. With project and so on)
final Collection<Lock> locksToTake = myLocks.fromBuildFeaturesAsMap(features).values();
if (!locksToTake.isEmpty()) {
// Collection<Lock> --> Collection<ResolvedLock>. For quoted - number of insufficient quotes, for custom -> custom values
final Map<Resource, String> unavailableLocks = myTakenLocks.getUnavailableLocks(locksToTake, takenLocksSupplier.get(), projectId, accessor, promotion);
if (!unavailableLocks.isEmpty()) {
reason = createWaitReason(unavailableLocks);
if (LOG.isDebugEnabled()) {
LOG.debug("Preventing start of the queued build [" + buildPromotion.getQueuedBuild() + "] with reason: [" + reason.getDescription() + "]");
}
} else {
storeResourcesAffinity(buildPromotion, projectId, takenLocksSupplier.get(), locksToTake, accessor, emulationMode); // assign ANY locks here
}
}
}
}
}
return reason;
}