Skip to content

Commit

Permalink
[JENKINS-21063] Indicate in icon (or tooltip) if a release build failed.
Browse files Browse the repository at this point in the history
Failed release build is now indicated in badge/icon as well as tooltip. Also reworked dryrun badge to align.

Signed-off-by: Anders Hammar <anders@hammar.net>
  • Loading branch information
andham committed Dec 20, 2013
1 parent 0a16dc8 commit 8a166ef
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 15 deletions.
Expand Up @@ -47,13 +47,16 @@ public class M2ReleaseBadgeAction implements BuildBadgeAction {
* Version number that was released.
*/
private String versionNumber;

private boolean failedBuild;

/**
* Construct a new BadgeIcon to a Maven release build.
* Construct a new BadgeIcon to a Maven release build. The build is set as successful.
*/
public M2ReleaseBadgeAction(String versionNumber, boolean isDryRun) {
this.versionNumber = versionNumber;
this.isDryRun = isDryRun;
this.failedBuild = false;
}

public Object readResolve() {
Expand Down Expand Up @@ -95,7 +98,20 @@ public String getUrlName() {
* Gets the tooltip text that should be displayed to the user.
*/
public String getTooltipText() {
return isDryRun ? "Release (dryRun) - " + versionNumber : "Release - " + versionNumber;
StringBuilder str = new StringBuilder();

if (isFailedBuild()) {
str.append("Failed release");
} else {
str.append("Release");
}
if (isDryRun()) {
str.append(" (dryRun)");
}
str.append(" - ");
str.append(getVersionNumber());

return str.toString();
}

/**
Expand All @@ -111,4 +127,15 @@ public String getVersionNumber() {
public boolean isDryRun() {
return isDryRun;
}

/**
* Marks the build as failed.
*/
public void setFailedBuild(boolean isFailedBuild) {
this.failedBuild = isFailedBuild;
}

public boolean isFailedBuild() {
return failedBuild;
}
}
Expand Up @@ -184,13 +184,9 @@ public void buildEnvVars(Map<String, String> env) {
public boolean tearDown(@SuppressWarnings("rawtypes") AbstractBuild bld, BuildListener lstnr)
throws IOException, InterruptedException {
boolean retVal = true;

final MavenModuleSet mmSet = getModuleSet(bld);
M2ReleaseArgumentsAction args = bld.getAction(M2ReleaseArgumentsAction.class);

if (args.isDryRun()) {
lstnr.getLogger().println("[M2Release] its only a dryRun, no need to mark it for keep");
}

if (args.isCloseNexusStage() && !args.isDryRun()) {
StageClient client = new StageClient(new URL(getDescriptor().getNexusURL()), getDescriptor()
.getNexusUser(), getDescriptor().getNexusPassword());
Expand Down Expand Up @@ -223,6 +219,15 @@ public boolean tearDown(@SuppressWarnings("rawtypes") AbstractBuild bld, BuildLi
retVal = false;
}
}

if (bld.getResult() != null && !bld.getResult().isBetterOrEqualTo(Result.SUCCESS)) {
M2ReleaseBadgeAction badge = bld.getAction(M2ReleaseBadgeAction.class);
badge.setFailedBuild(true);
}

if (args.isDryRun()) {
lstnr.getLogger().println("[M2Release] its only a dryRun, no need to mark it for keep");
}
int buildsKept = 0;
if (bld.getResult() != null && bld.getResult().isBetterOrEqualTo(Result.SUCCESS) && !args.isDryRun()) {
if (numberOfReleaseBuildsToKeep > 0 || numberOfReleaseBuildsToKeep == -1) {
Expand Down Expand Up @@ -266,7 +271,7 @@ public boolean tearDown(@SuppressWarnings("rawtypes") AbstractBuild bld, BuildLi
}

/**
* evaluate if the specified build is a sucessful release build (not including dry runs)
* evaluate if the specified build is a successful release build (not including dry runs)
* @param run the run to check
* @return <code>true</code> if this is a successful release build that is not a dry run.
*/
Expand Down
@@ -1,8 +1,13 @@
<j:jelly xmlns:j="jelly:core">
<j:if test="${it.isDryRun()}">
<img width="16" height="16" title="${it.tooltipText}" src="${rootURL}/plugin/m2release/img/new-package.png"/>
</j:if>
<j:if test="${!it.isDryRun()}">
<img width="16" height="16" title="${it.tooltipText}" src="${imagesURL}/16x16/package.png"/>
</j:if>
</j:jelly>
<j:choose>
<j:when test="${it.isFailedBuild()}">
<img width="16" height="16" title="${it.tooltipText}" src="${rootURL}/plugin/m2release/img/releasebadge-failure.png"/>
</j:when>
<j:when test="${it.isDryRun()}">
<img width="16" height="16" title="${it.tooltipText}" src="${rootURL}/plugin/m2release/img/releasebadge-dryrun.png"/>
</j:when>
<j:otherwise>
<img width="16" height="16" title="${it.tooltipText}" src="${rootURL}/plugin/m2release/img/releasebadge.png"/>
</j:otherwise>
</j:choose>
</j:jelly>
Binary file removed src/main/webapp/img/new-package.png
Binary file not shown.
Binary file added src/main/webapp/img/releasebadge-dryrun.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/webapp/img/releasebadge-failure.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/webapp/img/releasebadge.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8a166ef

Please sign in to comment.