Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from christiangalsterer/JENKINS-25306
[JENKINS-25306] Build status badge for specific build of a job
- Loading branch information
Showing
6 changed files
with
143 additions
and
11 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
38 changes: 38 additions & 0 deletions
38
src/main/java/org/jenkinsci/plugins/badge/RunBadgeAction.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,38 @@ | ||
package org.jenkinsci.plugins.badge; | ||
|
||
import hudson.model.AbstractProject; | ||
import hudson.model.Action; | ||
import hudson.model.Run; | ||
import jenkins.model.Jenkins; | ||
import org.kohsuke.stapler.HttpResponse; | ||
|
||
public class RunBadgeAction implements Action { | ||
private final RunBadgeActionFactory factory; | ||
public final Run run; | ||
public final AbstractProject project; | ||
|
||
public RunBadgeAction(RunBadgeActionFactory factory, Run run) { | ||
this.factory = factory; | ||
this.run = run; | ||
this.project = (AbstractProject)run.getParent(); | ||
} | ||
|
||
public String getIconFileName() { | ||
return Jenkins.RESOURCE_PATH+"/plugin/embeddable-build-status/images/24x24/shield.png"; | ||
} | ||
|
||
public String getDisplayName() { | ||
return Messages.RunBadgeAction_DisplayName(); | ||
} | ||
|
||
public String getUrlName() { | ||
return "badge"; | ||
} | ||
|
||
/** | ||
* Serves the badge image. | ||
*/ | ||
public HttpResponse doIcon() { | ||
return factory.getImage(run.getIconColor()); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/org/jenkinsci/plugins/badge/RunBadgeActionFactory.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,27 @@ | ||
package org.jenkinsci.plugins.badge; | ||
|
||
import hudson.Extension; | ||
import hudson.model.*; | ||
|
||
import java.io.IOException; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
|
||
@Extension | ||
public class RunBadgeActionFactory extends TransientBuildActionFactory { | ||
|
||
private final ImageResolver iconResolver; | ||
|
||
public RunBadgeActionFactory() throws IOException { | ||
iconResolver = new ImageResolver(); | ||
} | ||
|
||
@Override | ||
public Collection<? extends Action> createFor(Run target) { | ||
return Collections.singleton(new RunBadgeAction(this, target)); | ||
} | ||
|
||
public StatusImage getImage(BallColor color) { | ||
return iconResolver.getImage(color); | ||
} | ||
} |
3 changes: 2 additions & 1 deletion
3
src/main/resources/org/jenkinsci/plugins/badge/Messages.properties
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
BadgeAction.DisplayName=Embeddable Build Status | ||
ViewStatus.Permission=This permission grants the ability to view the build status via embeddable build status plugin. | ||
RunBadgeAction.DisplayName=Embeddable Build Status | ||
ViewStatus.Permission=This permission grants the ability to view the build status via embeddable build status plugin. |
3 changes: 2 additions & 1 deletion
3
src/main/resources/org/jenkinsci/plugins/badge/Messages_ja.properties
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
BadgeAction.DisplayName=\u57CB\u3081\u8FBC\u307F\u7528\u30B9\u30C6\u30FC\u30BF\u30B9\u30A2\u30A4\u30B3\u30F3 | ||
BadgeAction.DisplayName=\u57CB\u3081\u8FBC\u307F\u7528\u30B9\u30C6\u30FC\u30BF\u30B9\u30A2\u30A4\u30B3\u30F3 | ||
RunBadgeAction.DisplayName=\u57CB\u3081\u8FBC\u307F\u7528\u30B9\u30C6\u30FC\u30BF\u30B9\u30A2\u30A4\u30B3\u30F3 |
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