summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakozak2011-11-24 09:17:32 (EST)
committer Winston Prakash2011-12-01 20:47:27 (EST)
commitee949b7379d8724cf7150b877bd78cede65f5679 (patch)
treeda94dbf90a2f3f67802b9b32a6ea8035f589da3a
parentc840a8144eb3ddc99385f11a70bd0e0afe9739a4 (diff)
downloadorg.eclipse.hudson.core-ee949b7379d8724cf7150b877bd78cede65f5679.zip
org.eclipse.hudson.core-ee949b7379d8724cf7150b877bd78cede65f5679.tar.gz
org.eclipse.hudson.core-ee949b7379d8724cf7150b877bd78cede65f5679.tar.bz2
Fixed highlighting of the parameters in case of cascading overriding.
Signed-off-by: Winston Prakash <winston.prakash@gmail.com>
-rw-r--r--hudson-core/src/main/java/hudson/matrix/MatrixBuild.java137
-rw-r--r--hudson-core/src/main/resources/hudson/model/ParametersDefinitionProperty/config.jelly10
-rw-r--r--hudson-core/src/main/resources/lib/form/nested.jelly21
3 files changed, 103 insertions, 65 deletions
diff --git a/hudson-core/src/main/java/hudson/matrix/MatrixBuild.java b/hudson-core/src/main/java/hudson/matrix/MatrixBuild.java
index 67b78b8..9422d70 100644
--- a/hudson-core/src/main/java/hudson/matrix/MatrixBuild.java
+++ b/hudson-core/src/main/java/hudson/matrix/MatrixBuild.java
@@ -50,7 +50,7 @@ import org.kohsuke.stapler.StaplerResponse;
*
* @author Kohsuke Kawaguchi
*/
-public class MatrixBuild extends Build<MatrixProject,MatrixBuild> {
+public class MatrixBuild extends Build<MatrixProject, MatrixBuild> {
private AxisList axes;
public MatrixBuild(MatrixProject job) throws IOException {
@@ -67,8 +67,9 @@ public class MatrixBuild extends Build<MatrixProject,MatrixBuild> {
public Object readResolve() {
// MatrixBuild.axes added in 1.285; default to parent axes for old data
- if (axes==null)
+ if (axes == null) {
axes = getParent().getAxes();
+ }
return this;
}
@@ -78,7 +79,10 @@ public class MatrixBuild extends Build<MatrixProject,MatrixBuild> {
public final class RunPtr {
//TODO: review and check whether we can do it private
public final Combination combination;
- private RunPtr(Combination c) { this.combination=c; }
+
+ private RunPtr(Combination c) {
+ this.combination = c;
+ }
public MatrixRun getRun() {
return MatrixBuild.this.getRun(combination);
@@ -90,10 +94,13 @@ public class MatrixBuild extends Build<MatrixProject,MatrixBuild> {
public String getTooltip() {
MatrixRun r = getRun();
- if(r!=null) return r.getIconColor().getDescription();
+ if (r != null) {
+ return r.getIconColor().getDescription();
+ }
Queue.Item item = Hudson.getInstance().getQueue().getItem(getParent().getItem(combination));
- if(item!=null)
+ if (item != null) {
return item.getWhy();
+ }
return null; // fall back
}
@@ -117,7 +124,9 @@ public class MatrixBuild extends Build<MatrixProject,MatrixBuild> {
*/
public MatrixRun getRun(Combination c) {
MatrixConfiguration config = getParent().getItem(c);
- if(config==null) return null;
+ if (config == null) {
+ return null;
+ }
return config.getBuildByNumber(getNumber());
}
@@ -126,9 +135,11 @@ public class MatrixBuild extends Build<MatrixProject,MatrixBuild> {
*/
public List<MatrixRun> getRuns() {
List<MatrixRun> r = new ArrayList<MatrixRun>();
- for(MatrixConfiguration c : getParent().getItems()) {
+ for (MatrixConfiguration c : getParent().getItems()) {
MatrixRun b = c.getBuildByNumber(getNumber());
- if (b != null) r.add(b);
+ if (b != null) {
+ r.add(b);
+ }
}
return r;
}
@@ -137,12 +148,13 @@ public class MatrixBuild extends Build<MatrixProject,MatrixBuild> {
public Object getDynamic(String token, StaplerRequest req, StaplerResponse rsp) {
try {
MatrixRun item = getRun(Combination.fromString(token));
- if(item!=null)
+ if (item != null) {
return item;
+ }
} catch (IllegalArgumentException _) {
// failed to parse the token as Combination. Must be something else
}
- return super.getDynamic(token,req,rsp);
+ return super.getDynamic(token, req, rsp);
}
@Override
@@ -153,8 +165,9 @@ public class MatrixBuild extends Build<MatrixProject,MatrixBuild> {
@Override
public Fingerprint.RangeSet getDownstreamRelationship(AbstractProject that) {
Fingerprint.RangeSet rs = super.getDownstreamRelationship(that);
- for(MatrixRun run : getRuns())
+ for (MatrixRun run : getRuns()) {
rs.add(run.getDownstreamRelationship(that));
+ }
return rs;
}
@@ -170,8 +183,9 @@ public class MatrixBuild extends Build<MatrixProject,MatrixBuild> {
if (pub instanceof MatrixAggregatable) {
MatrixAggregatable ma = (MatrixAggregatable) pub;
MatrixAggregator a = ma.createAggregator(MatrixBuild.this, launcher, listener);
- if(a!=null)
+ if (a != null) {
aggregators.add(a);
+ }
}
}
@@ -180,79 +194,89 @@ public class MatrixBuild extends Build<MatrixProject,MatrixBuild> {
if (prop instanceof MatrixAggregatable) {
MatrixAggregatable ma = (MatrixAggregatable) prop;
MatrixAggregator a = ma.createAggregator(MatrixBuild.this, launcher, listener);
- if(a!=null)
+ if (a != null) {
aggregators.add(a);
+ }
}
}
axes = p.getAxes();
Collection<MatrixConfiguration> activeConfigurations = p.getActiveConfigurations();
final int n = getNumber();
-
+
String touchStoneFilter = p.getTouchStoneCombinationFilter();
Collection<MatrixConfiguration> touchStoneConfigurations = new HashSet<MatrixConfiguration>();
Collection<MatrixConfiguration> delayedConfigurations = new HashSet<MatrixConfiguration>();
- for (MatrixConfiguration c: activeConfigurations) {
+ for (MatrixConfiguration c : activeConfigurations) {
AxisList axes = p.getAxes();
String touchStoneCombinationFilter = p.getTouchStoneCombinationFilter();
- if (touchStoneFilter != null && c.getCombination().evalGroovyExpression(axes, touchStoneCombinationFilter)) {
+ if (touchStoneFilter != null && c.getCombination()
+ .evalGroovyExpression(axes, touchStoneCombinationFilter)) {
touchStoneConfigurations.add(c);
} else {
delayedConfigurations.add(c);
}
}
- for (MatrixAggregator a : aggregators)
- if(!a.startBuild())
+ for (MatrixAggregator a : aggregators) {
+ if (!a.startBuild()) {
return Result.FAILURE;
+ }
+ }
try {
- if(!p.isRunSequentially())
- for(MatrixConfiguration c : touchStoneConfigurations)
+ if (!p.isRunSequentially()) {
+ for (MatrixConfiguration c : touchStoneConfigurations) {
scheduleConfigurationBuild(logger, c);
+ }
+ }
Result r = Result.SUCCESS;
for (MatrixConfiguration c : touchStoneConfigurations) {
- if(p.isRunSequentially())
+ if (p.isRunSequentially()) {
scheduleConfigurationBuild(logger, c);
+ }
Result buildResult = waitForCompletion(listener, c);
r = r.combine(buildResult);
}
-
+
if (p.getTouchStoneResultCondition() != null && r.isWorseThan(p.getTouchStoneResultCondition())) {
logger.printf("Touchstone configurations resulted in %s, so aborting...\n", r);
return r;
}
-
- if(!p.isRunSequentially())
- for(MatrixConfiguration c : delayedConfigurations)
+
+ if (!p.isRunSequentially()) {
+ for (MatrixConfiguration c : delayedConfigurations) {
scheduleConfigurationBuild(logger, c);
+ }
+ }
for (MatrixConfiguration c : delayedConfigurations) {
- if(p.isRunSequentially())
+ if (p.isRunSequentially()) {
scheduleConfigurationBuild(logger, c);
+ }
Result buildResult = waitForCompletion(listener, c);
r = r.combine(buildResult);
}
return r;
- } catch( InterruptedException e ) {
+ } catch (InterruptedException e) {
logger.println("Aborted");
return Result.ABORTED;
} catch (AggregatorFailureException e) {
return Result.FAILURE;
- }
- finally {
+ } finally {
// if the build was aborted in the middle. Cancel all the configuration builds.
Queue q = Hudson.getInstance().getQueue();
- synchronized(q) {// avoid micro-locking in q.cancel.
+ synchronized (q) {// avoid micro-locking in q.cancel.
for (MatrixConfiguration c : activeConfigurations) {
- if(q.cancel(c))
+ if (q.cancel(c)) {
logger.println(Messages.MatrixBuild_Cancelled(c.getDisplayName()));
+ }
MatrixRun b = c.getBuildByNumber(n);
- if(b!=null) {
+ if (b != null) {
Executor exe = b.getExecutor();
- if(exe!=null) {
+ if (exe != null) {
logger.println(Messages.MatrixBuild_Interrupting(b.getDisplayName()));
exe.interrupt();
}
@@ -261,28 +285,31 @@ public class MatrixBuild extends Build<MatrixProject,MatrixBuild> {
}
}
}
-
- private Result waitForCompletion(BuildListener listener, MatrixConfiguration c) throws InterruptedException, IOException, AggregatorFailureException {
+
+ private Result waitForCompletion(BuildListener listener, MatrixConfiguration c)
+ throws InterruptedException, IOException, AggregatorFailureException {
String whyInQueue = "";
long startTime = System.currentTimeMillis();
// wait for the completion
int appearsCancelledCount = 0;
- while(true) {
+ while (true) {
MatrixRun b = c.getBuildByNumber(getNumber());
// two ways to get beyond this. one is that the build starts and gets done,
// or the build gets cancelled before it even started.
Result buildResult = null;
- if(b!=null && !b.isBuilding())
+ if (b != null && !b.isBuilding()) {
buildResult = b.getResult();
+ }
Queue.Item qi = c.getQueueItem();
- if(b==null && qi==null)
+ if (b == null && qi == null) {
appearsCancelledCount++;
- else
+ } else {
appearsCancelledCount = 0;
+ }
- if(appearsCancelledCount>=5) {
+ if (appearsCancelledCount >= 5) {
// there's conceivably a race condition in computating b and qi, as their computation
// are not synchronized. There are indeed several reports of Hudson incorrectly assuming
// builds being cancelled. See
@@ -294,22 +321,24 @@ public class MatrixBuild extends Build<MatrixProject,MatrixBuild> {
buildResult = Result.ABORTED;
}
- if(buildResult!=null) {
- for (MatrixAggregator a : aggregators)
- if(!a.endRun(b))
+ if (buildResult != null) {
+ for (MatrixAggregator a : aggregators) {
+ if (!a.endRun(b)) {
throw new AggregatorFailureException();
+ }
+ }
return buildResult;
- }
+ }
- if(qi!=null) {
+ if (qi != null) {
// if the build seems to be stuck in the queue, display why
String why = qi.getWhy();
- if(!why.equals(whyInQueue) && System.currentTimeMillis()-startTime>5000) {
- listener.getLogger().println(c.getDisplayName()+" is still in the queue: "+why);
+ if (!why.equals(whyInQueue) && System.currentTimeMillis() - startTime > 5000) {
+ listener.getLogger().println(c.getDisplayName() + " is still in the queue: " + why);
whyInQueue = why;
}
}
-
+
Thread.sleep(1000);
}
}
@@ -320,10 +349,11 @@ public class MatrixBuild extends Build<MatrixProject,MatrixBuild> {
}
public void post2(BuildListener listener) throws Exception {
- for (MatrixAggregator a : aggregators)
+ for (MatrixAggregator a : aggregators) {
a.endBuild();
+ }
}
-
+
@Override
protected Lease decideWorkspace(Node n, WorkspaceList wsl) throws IOException, InterruptedException {
String customWorkspace = getProject().getCustomWorkspace();
@@ -331,14 +361,15 @@ public class MatrixBuild extends Build<MatrixProject,MatrixBuild> {
// we allow custom workspaces to be concurrently used between jobs.
return Lease.createDummyLease(n.getRootPath().child(getEnvironment(listener).expand(customWorkspace)));
}
- return super.decideWorkspace(n,wsl);
+ return super.decideWorkspace(n, wsl);
}
-
+
}
/**
* A private exception to help maintain the correct control flow after extracting the 'waitForCompletion' method
*/
- private static class AggregatorFailureException extends Exception {}
+ private static class AggregatorFailureException extends Exception {
+ }
}
diff --git a/hudson-core/src/main/resources/hudson/model/ParametersDefinitionProperty/config.jelly b/hudson-core/src/main/resources/hudson/model/ParametersDefinitionProperty/config.jelly
index 2a2da3e..de2f64e 100644
--- a/hudson-core/src/main/resources/hudson/model/ParametersDefinitionProperty/config.jelly
+++ b/hudson-core/src/main/resources/hudson/model/ParametersDefinitionProperty/config.jelly
@@ -9,7 +9,7 @@
#
# Contributors:
#
-# Kohsuke Kawaguchi, Tom Huybrechts, Nikita Levyankov
+# Kohsuke Kawaguchi, Tom Huybrechts, Nikita Levyankov, Anton Kozak
#
#
#************************************************************************** -->
@@ -19,14 +19,16 @@
xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form"
xmlns:i="jelly:fmt" xmlns:p="/lib/hudson/project">
<j:set var="instancesProperty" value="${cu.getCopyOnWriteListProjectProperty(it, it.PARAMETERS_DEFINITION_JOB_PROPERTY_PROPERTY_NAME)}"/>
+ <j:set var="isParametersOverridden" value="${instancesProperty.isOverridden()}"/>
<f:optionalBlock name="parameterized" title="${%This build is parameterized}"
- isPropertyOverridden="${instancesProperty.isOverridden()}"
+ isPropertyOverridden="${isParametersOverridden}"
resetUrl="${jobUrl}/resetProjectProperty?propertyName=${instancesProperty.key}"
checked="${instance!=null}" help="/help/project-config/parameterized-build.html">
- <f:nested>
+ <f:nested isPropertyOverridden="${isParametersOverridden}">
<f:hetero-list name="parameter" hasHeader="true"
+ isPropertyOverridden="${isParametersOverridden}"
descriptors="${h.getParameterDescriptors()}" items="${instance.parameterDefinitions}"
addCaption="${%Add Parameter}" />
</f:nested>
</f:optionalBlock>
-</j:jelly>
+</j:jelly> \ No newline at end of file
diff --git a/hudson-core/src/main/resources/lib/form/nested.jelly b/hudson-core/src/main/resources/lib/form/nested.jelly
index fc49bf5..9213e8e 100644
--- a/hudson-core/src/main/resources/lib/form/nested.jelly
+++ b/hudson-core/src/main/resources/lib/form/nested.jelly
@@ -1,6 +1,6 @@
<!-- **************************************************************************
#
-# Copyright (c) 2004-2009 Oracle Corporation.
+# Copyright (c) 2004-2011 Oracle Corporation.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
@@ -9,7 +9,7 @@
#
# Contributors:
#
-# Kohsuke Kawaguchi
+# Kohsuke Kawaguchi, Anton Kozak
#
#
#************************************************************************** -->
@@ -19,10 +19,15 @@
Used to display indented nested portion of the form
-->
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
- <tr>
- <td colspan="2"/>
- <td colspan="2">
- <d:invokeBody />
- </td>
- </tr>
+ <st:documentation>
+ <st:attribute name="isPropertyOverridden">
+ if present and true - the column will be highlight as overridden cascading property.
+ </st:attribute>
+ </st:documentation>
+ <tr>
+ <td colspan="2" class="${attrs.isPropertyOverridden? 'modified' :''}"/>
+ <td colspan="2">
+ <d:invokeBody />
+ </td>
+ </tr>
</j:jelly>