Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[JENKINS-23552] Replace "Allow priorities directly on Jobs"
* Added new JobProperty Strategy * Removed code for special handling of priorities on Jobs * Only show the JobProperty if some JobGroup is using it * Removed the checkbox on the main config page
- Loading branch information
Showing
8 changed files
with
110 additions
and
33 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
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
75 changes: 75 additions & 0 deletions
75
src/main/java/jenkins/advancedqueue/priority/strategy/JobPropertyStrategy.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,75 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright (c) 2014, Magnus Sandberg | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
package jenkins.advancedqueue.priority.strategy; | ||
|
||
import hudson.Extension; | ||
import hudson.model.Job; | ||
import hudson.model.Queue; | ||
import hudson.model.Queue.Item; | ||
import jenkins.advancedqueue.AdvancedQueueSorterJobProperty; | ||
|
||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
/** | ||
* @author Magnus Sandberg | ||
* @since 3.0 | ||
*/ | ||
public class JobPropertyStrategy extends AbstractDynamicPriorityStrategy { | ||
|
||
@Extension | ||
public static class UserIdCauseStrategyDescriptor extends AbstractDynamicPriorityStrategyDescriptor { | ||
|
||
public UserIdCauseStrategyDescriptor() { | ||
super("Take the priority from Property on the Job"); | ||
} | ||
|
||
} | ||
|
||
@DataBoundConstructor | ||
public JobPropertyStrategy() { | ||
} | ||
|
||
|
||
private Integer getPriorityInternal(Queue.Item item) { | ||
if(item.task instanceof Job<?, ?>) { | ||
Job<?, ?> job = (Job<?, ?>) item.task; | ||
AdvancedQueueSorterJobProperty priorityProperty = job.getProperty(AdvancedQueueSorterJobProperty.class); | ||
if (priorityProperty != null && priorityProperty.getUseJobPriority()) { | ||
return priorityProperty.priority; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean isApplicable(Queue.Item item) { | ||
return getPriorityInternal(item) != null; | ||
} | ||
|
||
@Override | ||
public int getPriority(Item item) { | ||
return getPriorityInternal(item); | ||
} | ||
|
||
} |
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
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
3 changes: 3 additions & 0 deletions
3
src/main/resources/jenkins/advancedqueue/priority/strategy/JobPropertyStrategy/config.jelly
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,3 @@ | ||
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form" xmlns:l="/lib/layout" xmlns:st="jelly:stapler"> | ||
<f:description>Take the priority from the the Priority assigned directly on the Job.</f:description> | ||
</j:jelly> |