Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JENKINS-27966] Priority Sorter must not require matrix-project
- Loading branch information
Showing
4 changed files
with
64 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/java/jenkins/advancedqueue/PriorityConfigurationMatrixHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package jenkins.advancedqueue; | ||
|
||
import jenkins.advancedqueue.sorter.ItemInfo; | ||
import jenkins.advancedqueue.sorter.QueueItemCache; | ||
import hudson.matrix.MatrixConfiguration; | ||
import hudson.matrix.MatrixProject; | ||
import hudson.model.Job; | ||
|
||
class PriorityConfigurationMatrixHelper { | ||
|
||
boolean isMatrixConfiguration(Job<?, ?> job) { | ||
return job instanceof MatrixConfiguration; | ||
} | ||
|
||
PriorityConfigurationCallback getPriority(MatrixConfiguration matrixConfiguration, | ||
PriorityConfigurationCallback priorityCallback) { | ||
// [JENKINS-8597] | ||
// For MatrixConfiguration use the latest assigned Priority from the | ||
// MatrixProject | ||
MatrixProject matrixProject = matrixConfiguration.getParent(); | ||
priorityCallback.addDecisionLog(0, "Job is MatrixConfiguration [" + matrixProject.getName() + "] ..."); | ||
ItemInfo itemInfo = QueueItemCache.get().getItem(matrixProject.getName()); | ||
// Can be null (for example) at startup when the MatrixBuild got | ||
// lost (was running at | ||
// restart) | ||
if (itemInfo != null) { | ||
priorityCallback.addDecisionLog(0, "MatrixProject found in cache, using priority from queue-item [" | ||
+ itemInfo.getItemId() + "]"); | ||
return priorityCallback.setPrioritySelection(itemInfo.getPriority(), itemInfo.getJobGroupId(), | ||
itemInfo.getPriorityStrategy()); | ||
} | ||
priorityCallback.addDecisionLog(0, "MatrixProject not found in cache, assigning global default priority"); | ||
return priorityCallback.setPrioritySelection(PrioritySorterConfiguration.get().getStrategy() | ||
.getDefaultPriority()); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters