Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix JENKINS-17591
  • Loading branch information
gboissinot committed Aug 5, 2013
1 parent a7cb9f8 commit b9434ce
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/main/java/org/jenkinsci/lib/xtrigger/AbstractTrigger.java
Expand Up @@ -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.