Stop builds in the order they are provided from the CLI (#6456)

This commit is contained in:
Basil Crow authored and GitHub committed 2022-04-11 07:56:25 -07:00
1 parent a6fa7b3abd
commit bdfdbca821
1 file changed
+4 -2
@@ -31,8 +31,9 @@ import hudson.model.Item;
import hudson.model.Job;
import hudson.model.Run;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import jenkins.model.Jenkins;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
@@ -55,7 +56,8 @@ public class StopBuildsCommand extends CLICommand {
@Override
protected int run() throws Exception {
Jenkins jenkins = Jenkins.get();
final HashSet<String> names = new HashSet<>(jobNames);
// Deduplicate job names, but preserve the order specified by the user.
final Set<String> names = new LinkedHashSet<>(jobNames);
final List<Job> jobsToStop = new ArrayList<>();
for (final String jobName : names) {