Skip to content
Permalink
Browse files
Merge pull request #9 from jglick/Trigger-DependencyDeclarer-JENKINS-…
…22397

[JENKINS-22397] Show upstream project in dependency graph
  • Loading branch information
gboissinot committed Mar 28, 2014
2 parents cfca4f2 + 104cf3f commit 7d07d2e12168666b8d08c00fc7d76f15b24e0478
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 7d07d2e

Please sign in to comment.