aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Varghese2013-08-15 12:19:16 (EDT)
committerRoy Varghese2013-08-15 12:19:16 (EDT)
commit6aa2e2d3993a5d9ccb2a49a89459e54f81ac949e (patch)
treec0584916c14d20ba71a679c6800ee5a061698fc4
parent85b2b49951caa4d8daf80be2351151e5dd763821 (diff)
downloadorg.eclipse.hudson.core-6aa2e2d3993a5d9ccb2a49a89459e54f81ac949e.zip
org.eclipse.hudson.core-6aa2e2d3993a5d9ccb2a49a89459e54f81ac949e.tar.gz
org.eclipse.hudson.core-6aa2e2d3993a5d9ccb2a49a89459e54f81ac949e.tar.bz2
Fix 415001: Description Setter Plugin Not Updating Description in Build Historyrefs/changes/11/15511/1
Signed-off-by: Roy Varghese <rovarghe@gmail.com>
-rw-r--r--hudson-core/src/main/java/hudson/model/BuildHistory.java2
-rw-r--r--hudson-core/src/main/java/hudson/model/Run.java7
-rw-r--r--hudson-core/src/main/java/hudson/model/RunMap.java93
-rw-r--r--hudson-core/src/main/resources/lib/hudson/buildListTable.jelly2
4 files changed, 79 insertions, 25 deletions
diff --git a/hudson-core/src/main/java/hudson/model/BuildHistory.java b/hudson-core/src/main/java/hudson/model/BuildHistory.java
index 56e303b..b042e7e 100644
--- a/hudson-core/src/main/java/hudson/model/BuildHistory.java
+++ b/hudson-core/src/main/java/hudson/model/BuildHistory.java
@@ -64,6 +64,8 @@ public interface BuildHistory<JobT extends Job<JobT, RunT>, RunT extends Run<Job
String getBuiltOnNodeName();
String getDisplayName();
+ String getDescription();
+ String getTruncatedDescription();
String getFullDisplayName();
String getUrl();
diff --git a/hudson-core/src/main/java/hudson/model/Run.java b/hudson-core/src/main/java/hudson/model/Run.java
index 263ad19..d21e27d 100644
--- a/hudson-core/src/main/java/hudson/model/Run.java
+++ b/hudson-core/src/main/java/hudson/model/Run.java
@@ -526,7 +526,12 @@ public abstract class Run<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
*
* @return The length-limited description.
*/
- public String getTruncatedDescription() {
+ final public String getTruncatedDescription() {
+ return getTruncatedDescription(description);
+ }
+
+ static String getTruncatedDescription(String description) {
+
final int maxDescrLength = 100;
if (description == null || description.length() < maxDescrLength) {
return description;
diff --git a/hudson-core/src/main/java/hudson/model/RunMap.java b/hudson-core/src/main/java/hudson/model/RunMap.java
index 1e6eba8..3e8bcee 100644
--- a/hudson-core/src/main/java/hudson/model/RunMap.java
+++ b/hudson-core/src/main/java/hudson/model/RunMap.java
@@ -31,7 +31,9 @@ import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
import com.thoughtworks.xstream.io.xml.XppReader;
import hudson.Extension;
+import hudson.XmlFile;
import hudson.model.listeners.RunListener;
+import hudson.model.listeners.SaveableListener;
import hudson.tasks.test.AbstractTestResultAction;
import hudson.util.AtomicFileWriter;
import hudson.util.XStream2;
@@ -785,6 +787,7 @@ public final class RunMap<J extends Job<J, R>, R extends Run<J, R>>
long duration;
String fullDisplayName;
String displayName;
+ String description;
String url;
String builtOnStr;
@@ -800,6 +803,23 @@ public final class RunMap<J extends Job<J, R>, R extends Run<J, R>>
RunValue() {
}
+ static void update(Run run) {
+ // Updates a RunValue with the latest information from Run
+ final Object job = run.getParent();
+ if (job instanceof AbstractProject) {
+ final AbstractProject p = (AbstractProject) job;
+ RunValue rv = (RunValue) p.builds.builds.get(run.getNumber());
+ if ( rv != null ) {
+ // Can happen if build has not yet been added to project
+ // or is in the process of being added.
+ rv.sync();
+ p.builds.recalcMarkers();
+ p.builds.saveToRunMapXml();
+ }
+
+ }
+ }
+
protected void sync() {
R build = getBuild();
if ( build == null || build.hasLoadFailure() ) {
@@ -812,6 +832,7 @@ public final class RunMap<J extends Job<J, R>, R extends Run<J, R>>
setLogUpdated( build.isLogUpdated());
setTimeInMillis( build.getTimeInMillis());
setDisplayName( build.getDisplayName());
+ setDescription( build.getDescription());
setDuration( build.getDuration());
if ( build instanceof AbstractBuild) {
@@ -867,6 +888,14 @@ public final class RunMap<J extends Job<J, R>, R extends Run<J, R>>
markDirty(true);
}
+ void setDescription(String desc) {
+ if ( StringUtils.equals(this.description, desc)) {
+ return;
+ }
+ this.description = desc;
+ markDirty(true);
+ }
+
void setFullDisplayName(String name) {
if ( StringUtils.equals(this.fullDisplayName, name)) {
return;
@@ -991,6 +1020,16 @@ public final class RunMap<J extends Job<J, R>, R extends Run<J, R>>
}
@Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public String getTruncatedDescription() {
+ return Run.getTruncatedDescription(description);
+ }
+
+ @Override
public String getFullDisplayName() {
return fullDisplayName;
}
@@ -1278,18 +1317,24 @@ public final class RunMap<J extends Job<J, R>, R extends Run<J, R>>
writer.setValue(String.valueOf(current.buildNumber));
writer.endNode();
- if ( current.displayName != null) {
+ if ( StringUtils.isNotEmpty(current.displayName)) {
writer.startNode("displayName");
writer.setValue(current.displayName);
writer.endNode();
}
- if ( current.fullDisplayName != null) {
+ if ( StringUtils.isNotEmpty(current.fullDisplayName)) {
writer.startNode("fullDisplayName");
writer.setValue(current.fullDisplayName);
writer.endNode();
}
+ if ( StringUtils.isNotEmpty(current.description )) {
+ writer.startNode("description");
+ writer.setValue(current.description);
+ writer.endNode();
+ }
+
writer.startNode("buildDir");
writer.setValue( current.relativeBuildDir(buildsDir));
writer.endNode();
@@ -1356,6 +1401,9 @@ public final class RunMap<J extends Job<J, R>, R extends Run<J, R>>
else if ( "fullDisplayName".equals(name)) {
rv.fullDisplayName = reader.getValue();
}
+ else if ( "description".equals(name)) {
+ rv.description = reader.getValue();
+ }
else if ( "buildDir".equals(name)) {
rv.key.buildsDir = this.buildsDir;
rv.key.buildDir = reader.getValue();
@@ -1542,45 +1590,44 @@ public final class RunMap<J extends Job<J, R>, R extends Run<J, R>>
*/
@Extension
public static class RunValueUpdater extends RunListener<Run> {
-
-
- private void update(Run run) {
- // Updates a RunValue with the latest information from Run
- final Object job = run.getParent();
- if (job instanceof AbstractProject) {
- final AbstractProject p = (AbstractProject) job;
- RunValue rv = (RunValue) p.builds.builds.get(run.getNumber());
- rv.sync();
- p.builds.recalcMarkers();
- p.builds.saveToRunMapXml();
-
- }
- }
@Override
public void onCompleted(Run r, TaskListener listener) {
- update(r);
+ RunValue.update(r);
}
@Override
public void onFinalized(Run r) {
- update(r);
+ RunValue.update(r);
}
@Override
public void onStarted(Run r, TaskListener listener) {
- update(r);
+ RunValue.update(r);
}
@Override
public void onDeleted(Run r) {
- update(r);
+ RunValue.update(r);
}
-
-
-
}
+ /**
+ * This detects changes to the build configuration, which may
+ * happen after the build has completed.
+ */
+ @Extension
+ public static class RunValueUpdater2 extends SaveableListener {
+
+ @Override
+ public void onChange(Saveable saveable, XmlFile file) {
+ if (saveable instanceof Run) {
+ RunValue.update((Run)saveable);
+ }
+ }
+
+
+ }
public static class ConverterImpl implements Converter {
diff --git a/hudson-core/src/main/resources/lib/hudson/buildListTable.jelly b/hudson-core/src/main/resources/lib/hudson/buildListTable.jelly
index 6b26b8a..a6411c6 100644
--- a/hudson-core/src/main/resources/lib/hudson/buildListTable.jelly
+++ b/hudson-core/src/main/resources/lib/hudson/buildListTable.jelly
@@ -51,7 +51,7 @@
</a>
</td>
<td>
- <a href="${jobBaseUrl}${b.parent.url}">${b.parent.fullDisplayName}</a>
+ <a href="${jobBaseUrl}${b.parent.url}">${b.parent.displayName}</a>
<st:nbsp/>
<a href="${jobBaseUrl}${b.url}">#${b.number}</a>
</td>