forked from bklarson/Jenkins-repo-plugin
-
Notifications
You must be signed in to change notification settings - Fork 86
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 #57 from willi1s/JENKINS-59923_manifest_action
[JENKINS-59923] Replaced TagAction with new ManifestAction
- Loading branch information
Showing
6 changed files
with
153 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright (c) 2010, Brad Larson | ||
* | ||
* 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 hudson.plugins.repo; | ||
|
||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
import org.kohsuke.stapler.export.ExportedBean; | ||
|
||
import hudson.model.BuildBadgeAction; | ||
import hudson.model.Run; | ||
import jenkins.model.RunAction2; | ||
|
||
/** | ||
* A Manifest Action displays the static manifest information needed | ||
* to recreate the exact state of the repository when the build was run. | ||
*/ | ||
@ExportedBean(defaultVisibility = 999) | ||
public class ManifestAction implements RunAction2, BuildBadgeAction { | ||
|
||
private static Logger debug = Logger | ||
.getLogger("hudson.plugins.repo.ManifestAction"); | ||
|
||
private transient Run<?, ?> run; | ||
|
||
/** | ||
* Constructs the manifest action object. | ||
* @param run Build whose manifest we wish to display. | ||
*/ | ||
ManifestAction(final Run<?, ?> run) { | ||
this.run = run; | ||
} | ||
|
||
@Override | ||
public void onAttached(final Run<?, ?> r) { | ||
this.run = r; | ||
} | ||
|
||
@Override | ||
public void onLoad(final Run<?, ?> r) { | ||
this.run = r; | ||
} | ||
|
||
/** | ||
* Getter for the run property. | ||
*/ | ||
public Run<?, ?> getRun() { | ||
return run; | ||
} | ||
|
||
/** | ||
* Returns the filename to use as the badge. | ||
*/ | ||
public String getIconFileName() { | ||
return "star.gif"; | ||
} | ||
|
||
/** | ||
* Returns the display name to use for the action. | ||
*/ | ||
public String getDisplayName() { | ||
return "Repo Manifest"; | ||
} | ||
|
||
/** | ||
* Returns the name of the Url to use for the action. | ||
*/ | ||
public final String getUrlName() { | ||
return "repo-manifest"; | ||
} | ||
|
||
/** | ||
* Gets a String representation of the static manifest for this repo snapshot. | ||
*/ | ||
public String getManifest() { | ||
String result = ""; | ||
try { | ||
final RevisionState revisionState = run.getAction(RevisionState.class); | ||
if (revisionState != null) { | ||
result = revisionState.getManifest(); | ||
} | ||
} catch (Exception e) { | ||
debug.log(Level.WARNING, "Error getting revision state {0}", e.getMessage()); | ||
} | ||
return result; | ||
} | ||
} |
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
8 changes: 8 additions & 0 deletions
8
src/main/resources/hudson/plugins/repo/ManifestAction/badge.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,8 @@ | ||
<?jelly escape-by-default='true'?> | ||
|
||
<a href="${rootURL}/${it.run.url}${it.urlName}"> | ||
<img width="16" height="16" | ||
tooltip="${it.displayName}" | ||
alt="[manifest]" | ||
src="${imagesURL}/16x16/${it.iconFileName}"/> | ||
</a> |
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
11 changes: 0 additions & 11 deletions
11
src/main/resources/hudson/plugins/repo/TagAction/badge.jelly
This file was deleted.
Oops, something went wrong.