Skip to content
Permalink
Browse files
[JENKINS-22397] Take advantage of core API (when merged) to show the …
…upstream project in the dependency graph.
  • Loading branch information
jglick committed Mar 28, 2014
1 parent cfca4f2 commit 104cf3f22fe1af9a0f4c0dce07ab09ca4c71e19d
Showing with 24 additions and 1 deletion.
  1. +24 −1 src/main/java/org/jenkinsci/plugins/buildresulttrigger/BuildResultTrigger.java
@@ -28,15 +28,17 @@
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.logging.Level;
import jenkins.model.DependencyDeclarer;

/**
* @author Gregory Boissinot
*/
public class BuildResultTrigger extends AbstractTriggerByFullContext<BuildResultTriggerContext> {
public class BuildResultTrigger extends AbstractTriggerByFullContext<BuildResultTriggerContext> implements DependencyDeclarer {

private boolean combinedJobs;

@@ -72,6 +74,27 @@ public File getLogFile() {
return Collections.singleton(action);
}

@Override
public void buildDependencyGraph(AbstractProject ap, DependencyGraph dg) {
if (job instanceof AbstractProject) {
for (BuildResultTriggerInfo info : jobsInfo) {
for (String jobName : info.getJobNamesAsArray()) {
AbstractProject upstream = Jenkins.getInstance().getItem(jobName, job, AbstractProject.class);
if (upstream != null) {
dg.addDependency(new DependencyGraph.Dependency(upstream, (AbstractProject) job) {
@Override
public boolean shouldTriggerBuild(AbstractBuild build, TaskListener listener, List<Action> actions) {
// Do not let BuildTrigger start the downstream build as a result; let BuildResultTrigger decide.
// If BuildResultTrigger were rewritten to not use polling, this method could actually do the status check instead.
return false;
}
});
}
}
}
}
}

public final class InternalBuildResultTriggerAction extends BuildResultTriggerAction {

private transient String actionTitle;

0 comments on commit 104cf3f

Please sign in to comment.