Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using StepExecution.acceptAll #974

Merged
merged 2 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@
<scope>import</scope>
<type>pom</type>
</dependency>
<!-- TODO until in BOM: -->
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-step-api</artifactId>
<version>686.v603d058a_e148</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

package org.jenkinsci.plugins.workflow;

import com.google.common.base.Function;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.EnvVars;
Expand Down Expand Up @@ -214,17 +213,14 @@ public static final class Execution extends AbstractStepExecutionImpl {
}
}
public static void finish(final boolean terminate) {
StepExecution.applyAll(Execution.class, new Function<>() {
@Override public Void apply(Execution input) {
try {
input.listener.getLogger().println((terminate ? "finally" : "still") + " running as " + input.flow.getAuthentication().getName() + " from " + Thread.currentThread().getName());
if (terminate) {
input.getContext().onSuccess(null);
}
} catch (Exception x) {
input.getContext().onFailure(x);
StepExecution.acceptAll(Execution.class, input -> {
try {
input.listener.getLogger().println((terminate ? "finally" : "still") + " running as " + input.flow.getAuthentication().getName() + " from " + Thread.currentThread().getName());
if (terminate) {
input.getContext().onSuccess(null);
}
return null;
} catch (Exception x) {
input.getContext().onFailure(x);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.jenkinsci.plugins.workflow.cps;

import com.google.common.base.Function;
import com.google.common.collect.Sets;
import groovy.lang.Closure;
import hudson.model.Result;
Expand Down Expand Up @@ -151,22 +150,14 @@ public boolean start() throws Exception {
SemaphoreStep.waitForStart("b/1", b);
SemaphoreStep.waitForStart("c/1", b);
final RetainsBodyStep.Execution[] execs = new RetainsBodyStep.Execution[3];
StepExecution.applyAll(RetainsBodyStep.Execution.class, new Function<>() {
@Override public Void apply(RetainsBodyStep.Execution exec) {
execs[exec.count] = exec;
return null;
}
}).get();
StepExecution.acceptAll(RetainsBodyStep.Execution.class, exec -> execs[exec.count] = exec).get();
assertNotNull(execs[0]);
assertNotNull(execs[1]);
assertNotNull(execs[2]);
final Set<SemaphoreStep.Execution> semaphores = new HashSet<>();
StepExecution.applyAll(SemaphoreStep.Execution.class, new Function<>() {
@Override public Void apply(SemaphoreStep.Execution exec) {
if (exec.getStatus().matches("waiting on [ab]/1")) {
semaphores.add(exec);
}
return null;
StepExecution.acceptAll(SemaphoreStep.Execution.class, exec -> {
if (exec.getStatus().matches("waiting on [ab]/1")) {
semaphores.add(exec);
}
}).get();
assertThat(semaphores, iterableWithSize(2));
Expand Down
Loading