Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jenkinsci/parameterized-trigger-plugin
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 30ec9844e026c4a95eb3663e8c4c9d4a3d74fd01
Choose a base ref
..
head repository: jenkinsci/parameterized-trigger-plugin
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1d57a272897ff44c655425c703f7f387b8eb7a46
Choose a head ref
Showing with 46 additions and 27 deletions.
  1. +46 −27 src/main/java/hudson/plugins/parameterizedtrigger/TriggerBuilder.java
Original file line number Diff line number Diff line change
@@ -41,8 +41,10 @@
import hudson.model.Build;
import hudson.model.Queue;
import hudson.model.Result;
import hudson.model.Item;
import hudson.model.Cause;
import hudson.model.Cause.UpstreamCause;
import hudson.util.RunList;
import hudson.util.IOException2;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.stapler.DataBoundConstructor;
@@ -54,7 +56,6 @@
import java.lang.InterruptedException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

/**
* {@link Builder} that triggers other projects and optionally waits for their completion.
*
@@ -139,22 +140,36 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
listener.getLogger().println("Skipping " + HyperlinkNote.encodeTo('/'+ p.getUrl(), p.getFullDisplayName()) + ". The project is either disabled or the configuration has not been saved yet.");
continue;
}
for (Future<Run> future : futures.get(p)) {
try {

List<Future<Run>> runs = futures.get(p);
try {
for (Future<Run> future: runs) {
listener.getLogger().println("Waiting for the completion of " + HyperlinkNote.encodeTo('/'+ p.getUrl(), p.getFullDisplayName()));
Run b = future.get();
listener.getLogger().println(HyperlinkNote.encodeTo('/'+ b.getUrl(), b.getFullDisplayName()) + " completed. Result was "+b.getResult());
BuildInfoExporterAction.addBuildInfoExporterAction(build, b.getParent().getFullName(), b.getNumber(), b.getResult());

if(buildStepResult && config.getBlock().mapBuildStepResult(b.getResult())) {
build.setResult(config.getBlock().mapBuildResult(b.getResult()));
} else {
buildStepResult = false;
}
while (!runs.isEmpty()) {
List<Future<Run>> total_runs = new ArrayList<Future<Run>>(runs);
for (Future<Run> future: total_runs) {
if (!future.isDone()) {
Thread.sleep(100);
continue;
}

runs.remove(future);
Run b = future.get();
listener.getLogger().println(HyperlinkNote.encodeTo('/' + b.getUrl(), b.getFullDisplayName()) + " completed. Result was "+ b.getResult());
BuildInfoExporterAction.addBuildInfoExporterAction(build, b.getParent().getFullName(), b.getNumber(), b.getResult());

if(buildStepResult && config.getBlock().mapBuildStepResult(b.getResult())) {
build.setResult(config.getBlock().mapBuildResult(b.getResult()));
} else {
buildStepResult = false;
}
}
}
} catch (CancellationException x) {
throw new AbortException(p.getFullDisplayName() +" aborted.");
}
}

}
}
}
@@ -186,21 +201,25 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
}
}

for (Queue.LeftItem queueLeftItem : buildQueue.getLeftItems()) {
Build exec = (Build) queueLeftItem.getExecutable();
if (exec == null) {
continue;
}
UpstreamCause cause = (UpstreamCause) exec.getCause(UpstreamCause.class);
if (cause == null) {
continue;
}
if (cause.pointsTo(build)) {
try {
listener.getLogger().println("Aborting " + HyperlinkNote.encodeTo('/' + exec.getUrl(), exec.getFullDisplayName()));
exec.doStop();
} catch (javax.servlet.ServletException ex) {
// pass, build has already completed or aborted
List<Job> projectList = config.getJobs(build.getRootBuild().getProject().getParent(), env);
for (Job p : projectList) {
Item item = Jenkins.getInstance().getItem(p.getFullName(), p, Item.class);
for (Job job : item.getAllJobs()) {
RunList runList = job.getNewBuilds();
for (Iterator<Build> it = runList.iterator(); it.hasNext(); ) {
Build latestBuild = it.next();
UpstreamCause cause = (UpstreamCause) latestBuild.getCause(UpstreamCause.class);
if (cause == null) {
continue;
}
if (cause.pointsTo(build)) {
try {
listener.getLogger().println("Aborting " + HyperlinkNote.encodeTo('/' + latestBuild.getUrl(), latestBuild.getFullDisplayName()));
latestBuild.doStop();
} catch (javax.servlet.ServletException ex) {
// pass, build has already completed or aborted
}
}
}
}
}