Skip to content
Permalink
Browse files

Fix JENKINS-17591

  • Loading branch information
gboissinot committed Aug 5, 2013
1 parent a7cb9f8 commit b9434ceb27c4b1facd8302015d8edc7eb91ab216
Showing with 19 additions and 7 deletions.
  1. +19 −7 src/main/java/org/jenkinsci/lib/xtrigger/AbstractTrigger.java
@@ -466,30 +466,42 @@ private Node getMasterNode() {
}

private List<Node> getNodesLabel(AbstractProject project, Label label) {

Node lastBuildOnNode = project.getLastBuiltOn();
boolean isAPreviousBuildNode = lastBuildOnNode != null;

List<Node> result = new ArrayList<Node>();
List<Node> remainingNodes = new ArrayList<Node>();

Set<Node> nodes = label.getNodes();
for (Node node : nodes) {
if (node != null) {
if (!isAPreviousBuildNode) {
if (!isAPreviousBuildNode(project)) {
FilePath nodePath = node.getRootPath();
if (nodePath != null) {
result.add(node);
}
} else {
FilePath nodeRootPath = node.getRootPath();
if (nodeRootPath != null) {
if (nodeRootPath.equals(lastBuildOnNode.getRootPath())) {
//We recommend first the samed node
Node lastBuildOnNode = project.getLastBuiltOn();
if (lastBuildOnNode != null && nodeRootPath.equals(lastBuildOnNode.getRootPath())) {
result.add(0, node);
} else {
remainingNodes.add(node);
}
}
}
}
}
return result;

if (result.size() > 0) {
return result;
} else {
return remainingNodes;
}
}

private boolean isAPreviousBuildNode(AbstractProject project) {
Node lastBuildOnNode = project.getLastBuiltOn();
return lastBuildOnNode != null;
}

}

0 comments on commit b9434ce

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