-
-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Build Monitor supports Jenkins Claim Plugin (https://wiki.je…
…nkins-ci.org/display/JENKINS/Claim+plugin) This closes #19 and can address #9, provided that "unstable" and "aborted" builds are claimed.
- Loading branch information
Showing
20 changed files
with
386 additions
and
23 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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
4 changes: 4 additions & 0 deletions
4
.../java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/plugins/Augmentation.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,4 @@ | ||
package com.smartcodeltd.jenkinsci.plugins.buildmonitor.viewmodel.plugins; | ||
|
||
public interface Augmentation { | ||
} |
32 changes: 32 additions & 0 deletions
32
...ava/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/plugins/BuildAugmentor.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,32 @@ | ||
package com.smartcodeltd.jenkinsci.plugins.buildmonitor.viewmodel.plugins; | ||
|
||
import com.smartcodeltd.jenkinsci.plugins.buildmonitor.viewmodel.plugins.claim.Claim; | ||
import com.smartcodeltd.jenkinsci.plugins.buildmonitor.viewmodel.plugins.claim.Claimed; | ||
import com.smartcodeltd.jenkinsci.plugins.buildmonitor.viewmodel.plugins.claim.NotClaimed; | ||
import hudson.model.Run; | ||
import hudson.plugins.claim.ClaimBuildAction; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public class BuildAugmentor { | ||
|
||
private Set<Class<? extends Augmentation>> recognisedAugmentations = new HashSet<Class<? extends Augmentation>>(); | ||
|
||
public Claim detailsOf(Run<?, ?> build, Class<Claim> augmentation) { | ||
// todo: remove the below naive implementation with something better once there is more plugins to support ... | ||
if (recognisedAugmentations.contains(augmentation)) { | ||
ClaimBuildAction action = build.getAction(ClaimBuildAction.class); | ||
|
||
if (action != null) { | ||
return new Claimed(action); | ||
} | ||
} | ||
|
||
return new NotClaimed(); | ||
} | ||
|
||
public void support(Class<? extends Augmentation> typeOfAugmentation) { | ||
recognisedAugmentations.add(typeOfAugmentation); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...n/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/plugins/claim/Claim.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,9 @@ | ||
package com.smartcodeltd.jenkinsci.plugins.buildmonitor.viewmodel.plugins.claim; | ||
|
||
import com.smartcodeltd.jenkinsci.plugins.buildmonitor.viewmodel.plugins.Augmentation; | ||
|
||
public interface Claim extends Augmentation { | ||
public boolean wasMade(); | ||
public String author(); | ||
public String reason(); | ||
} |
30 changes: 30 additions & 0 deletions
30
...java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/plugins/claim/Claimed.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,30 @@ | ||
package com.smartcodeltd.jenkinsci.plugins.buildmonitor.viewmodel.plugins.claim; | ||
|
||
import hudson.plugins.claim.ClaimBuildAction; | ||
|
||
public class Claimed implements Claim { | ||
private final ClaimBuildAction action; | ||
|
||
public Claimed(ClaimBuildAction action) { | ||
this.action = action; | ||
} | ||
|
||
@Override | ||
public boolean wasMade() { | ||
return action.isClaimed(); | ||
} | ||
|
||
@Override | ||
public String author() { | ||
return action.getClaimedByName(); | ||
} | ||
|
||
@Override | ||
public String reason() { | ||
return action.getReason(); | ||
} | ||
|
||
public String toString() { | ||
return String.format("Claimed by \"%s\": \"%s\"", author(), reason()); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...a/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/plugins/claim/NotClaimed.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,22 @@ | ||
package com.smartcodeltd.jenkinsci.plugins.buildmonitor.viewmodel.plugins.claim; | ||
|
||
public class NotClaimed implements Claim { | ||
@Override | ||
public boolean wasMade() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public String author() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String reason() { | ||
return null; | ||
} | ||
|
||
public String toString() { | ||
return "Not claimed"; | ||
} | ||
} |
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
Oops, something went wrong.