Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@
import hudson.model.AutoCompletionCandidates;
import hudson.model.Computer;
import hudson.model.Executor;
import hudson.model.Job;
import hudson.model.Label;
import hudson.model.Node;
import hudson.model.Run;
import hudson.model.TaskListener;
import hudson.model.labels.LabelExpression;
import hudson.util.FormValidation;
import java.io.Serializable;
import java.util.Set;
Expand All @@ -49,6 +51,7 @@
import org.jenkinsci.plugins.workflow.steps.StepContext;
import org.jenkinsci.plugins.workflow.steps.StepDescriptor;
import org.jenkinsci.plugins.workflow.steps.StepExecution;
import org.kohsuke.stapler.AncestorInPath;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.QueryParameter;

Expand Down Expand Up @@ -95,22 +98,12 @@ public final class ExecutorStep extends Step implements Serializable {
return true;
}

// TODO copied from AbstractProjectDescriptor
public AutoCompletionCandidates doAutoCompleteLabel(@QueryParameter String value) {
AutoCompletionCandidates c = new AutoCompletionCandidates();
Jenkins j = Jenkins.getInstanceOrNull();
if (j != null) {
for (Label label : j.getLabels()) {
if (label.getName().startsWith(value)) {
c.add(label.getName());
}
}
}
return c;
return LabelExpression.autoComplete(value);
}

public FormValidation doCheckLabel(@QueryParameter String value) {
return AbstractProject.AbstractProjectDescriptor.validateLabelExpression(value, /* LabelValidator does not support Job */null);
public FormValidation doCheckLabel(@AncestorInPath Job<?, ?> job, @QueryParameter String value) {
return LabelExpression.validate(value, job);
}

@Override public Set<? extends Class<?>> getRequiredContext() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@

<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form">
<f:entry title="Label" field="label">
<f:textbox/>
<f:textbox autoCompleteDelimChar=" "/>
</f:entry>
</j:jelly>