Skip to content

Commit

Permalink
Merge pull request #201 from jglick/RetryStep.count
Browse files Browse the repository at this point in the history
Add form validation for `RetryStep.count`
  • Loading branch information
jglick authored Jul 7, 2022
2 parents c6812bb + 067e5ef commit fe95552
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/main/java/org/jenkinsci/plugins/workflow/steps/RetryStep.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.Extension;
import hudson.model.TaskListener;
import hudson.util.FormValidation;
import java.util.Collections;
import java.util.Set;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.QueryParameter;

/**
* Executes the body up to N times.
Expand Down Expand Up @@ -83,6 +85,16 @@ public Set<? extends Class<?>> getRequiredContext() {
return Collections.singleton(TaskListener.class);
}

public FormValidation doCheckCount(@QueryParameter int count) {
if (count < 1) {
return FormValidation.error("Count must be positive.");
} else if (count == 1) {
return FormValidation.warning("Count of one means that the retry step has no effect. Use ≥2.");
} else {
return FormValidation.ok();
}
}

}

}

0 comments on commit fe95552

Please sign in to comment.