Skip to content
Permalink
Browse files

[JENKINS-21063] Indicate in icon (or tooltip) if a release build failed.

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 8a166ef54883fdaf1e244cbd046d2e0908ee1adf
@@ -47,13 +47,16 @@
* 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() {
@@ -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();
}

/**
@@ -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;
}
}
@@ -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());
@@ -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) {
@@ -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.
*/
@@ -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 not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 8a166ef

Please sign in to comment.
You can’t perform that action at this time.