-
Notifications
You must be signed in to change notification settings - Fork 116
Add option to filter build with matching when counting current running jobs #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nmorey
wants to merge
1
commit into
jenkinsci:master
Choose a base branch
from
nmorey:match-parameters
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ | |
| import hudson.util.ListBoxModel; | ||
| import hudson.Util; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
|
|
@@ -20,6 +21,8 @@ | |
| import org.kohsuke.stapler.QueryParameter; | ||
| import org.kohsuke.stapler.StaplerRequest; | ||
|
|
||
| import org.apache.commons.lang.StringUtils; | ||
|
|
||
| public class ThrottleJobProperty extends JobProperty<AbstractProject<?,?>> { | ||
| // Moving category to categories, to support, well, multiple categories per job. | ||
| @Deprecated transient String category; | ||
|
|
@@ -30,6 +33,9 @@ public class ThrottleJobProperty extends JobProperty<AbstractProject<?,?>> { | |
| private boolean throttleEnabled; | ||
| private String throttleOption; | ||
|
|
||
| private final String combinationFilter; | ||
| private String[] matchParamsArray; | ||
|
|
||
| /** | ||
| * Store a config version so we're able to migrate config on various | ||
| * functionality upgrades. | ||
|
|
@@ -41,14 +47,24 @@ public ThrottleJobProperty(Integer maxConcurrentPerNode, | |
| Integer maxConcurrentTotal, | ||
| List<String> categories, | ||
| boolean throttleEnabled, | ||
| String throttleOption) { | ||
| String throttleOption, | ||
| String combinationFilter) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please change the tabulation to spaces |
||
| this.maxConcurrentPerNode = maxConcurrentPerNode == null ? 0 : maxConcurrentPerNode; | ||
| this.maxConcurrentTotal = maxConcurrentTotal == null ? 0 : maxConcurrentTotal; | ||
| this.categories = categories; | ||
| this.throttleEnabled = throttleEnabled; | ||
| this.throttleOption = throttleOption; | ||
| } | ||
| this.combinationFilter = combinationFilter; | ||
| this.matchParamsArray = StringUtils.split(this.combinationFilter, ","); | ||
|
|
||
| } | ||
| public ThrottleJobProperty(Integer maxConcurrentPerNode, | ||
| Integer maxConcurrentTotal, | ||
| List<String> categories, | ||
| boolean throttleEnabled, | ||
| String throttleOption){ | ||
| this(maxConcurrentPerNode, maxConcurrentTotal, categories, throttleEnabled, throttleOption, ""); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Usage of |
||
| } | ||
|
|
||
| /** | ||
| * Migrates deprecated/obsolete data | ||
|
|
@@ -91,7 +107,9 @@ public String getThrottleOption() { | |
| public List<String> getCategories() { | ||
| return categories; | ||
| } | ||
|
|
||
| public String getCombinationFilter(){ | ||
| return combinationFilter; | ||
| } | ||
| public Integer getMaxConcurrentPerNode() { | ||
| if (maxConcurrentPerNode == null) | ||
| maxConcurrentPerNode = 0; | ||
|
|
@@ -106,6 +124,14 @@ public Integer getMaxConcurrentTotal() { | |
| return maxConcurrentTotal; | ||
| } | ||
|
|
||
| public ArrayList<String> getMatchParamsArray(){ | ||
| if(this.matchParamsArray != null){ | ||
| return new ArrayList<String>(Arrays.asList(this.matchParamsArray)); | ||
| } else { | ||
| return new ArrayList<String>(); | ||
| } | ||
| } | ||
|
|
||
| @Extension | ||
| public static final class DescriptorImpl extends JobPropertyDescriptor { | ||
| private List<ThrottleCategory> categories; | ||
|
|
@@ -195,7 +221,23 @@ public ListBoxModel doFillCategoryItems() { | |
|
|
||
| return m; | ||
| } | ||
|
|
||
|
|
||
| /** | ||
| * Check whether the configuring model is parameterized. Called from jelly. | ||
| * | ||
| * Note: Caller should pass it for the model is not bound to | ||
| * {@link StaplerRequest#findAncestorObject(Class)} | ||
| * when called via hetelo-list. | ||
| * | ||
| * @param it | ||
| * @return true if the target model is {@link AbstractProject} is parameterized. | ||
| */ | ||
| public boolean isParameterizedProject(Object it) { | ||
| if ((it == null) || ! (it instanceof AbstractProject)) | ||
| return false; | ||
| AbstractProject p = (AbstractProject) it; | ||
| return p.isParameterized(); | ||
| } | ||
| } | ||
|
|
||
| public static final class ThrottleCategory extends AbstractDescribableImpl<ThrottleCategory> { | ||
|
|
||
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes in pom.xml should be removed