Skip to content

Commit

Permalink
Merge pull request #15 from Batmat/JENKINS-27002
Browse files Browse the repository at this point in the history
[Fixed JENKINS-27002] Claim "Stickiness" default value should be configurable
  • Loading branch information
ki82 committed Feb 23, 2015
2 parents 34bb51d + 41a784a commit e890781
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 1 deletion.
Expand Up @@ -34,7 +34,7 @@ public abstract class AbstractClaimBuildAction<T extends Saveable> extends Descr
private String claimedBy;
private String assignedBy;
private Date claimDate;
private boolean transientClaim;
private boolean transientClaim = !ClaimConfig.get().isStickyByDefault();

protected T owner;

Expand Down
24 changes: 24 additions & 0 deletions src/main/java/hudson/plugins/claim/ClaimConfig.java
Expand Up @@ -18,6 +18,10 @@ public ClaimConfig() {
*/
private boolean sendEmails;

/**
* Default global value for the stickiness of the build claims.
*/
private boolean stickyByDefault = true;

/**
* This human readable name is used in the configuration screen.
Expand All @@ -31,6 +35,7 @@ public boolean configure(StaplerRequest req, JSONObject formData) throws FormExc
// To persist global configuration information,
// set that to properties and call save().
sendEmails = formData.getBoolean("sendEmails");
stickyByDefault = formData.getBoolean("stickyByDefault");
save();
return super.configure(req,formData);
}
Expand All @@ -51,6 +56,25 @@ public void setSendEmails(boolean val) {
sendEmails = val;
}

/**
* Returns true if the claims should be sticky by default, false otherwise.
*
* @return true to make claims sticky by default, else false.
*/
public boolean isStickyByDefault() {
return stickyByDefault;
}

/**
* Sets the default stickiness behaviour for build claims.
*
* @param stickyByDefault
* the default stickiness value.
*/
public void setStickyByDefault(boolean stickyByDefault) {
this.stickyByDefault = stickyByDefault;
}

/**
* get the current claim configuration
* @return the global claim configuration
Expand Down
Expand Up @@ -3,5 +3,8 @@
<f:entry title="${%SendEmails}" field="sendEmails" help="/plugin/claim/help-sendEmails.html">
<f:checkbox />
</f:entry>
<f:entry title="${%StickyByDefault}" field="stickyByDefault" help="/plugin/claim/help-stickyByDefault.html">
<f:checkbox />
</f:entry>
</f:section>
</j:jelly>
@@ -1 +1,3 @@
SendEmails=Send emails when assigning/claiming builds
StickyByDefault=Sets the default value for stickiness when claiming builds

3 changes: 3 additions & 0 deletions src/main/webapp/help-stickyByDefault.html
@@ -0,0 +1,3 @@
<div>
Checking this option will make all <strong>future</strong> failed builds claims sticky by default.
</div>

0 comments on commit e890781

Please sign in to comment.