Skip to content
Permalink
Browse files

[JENKINS-46700] symbol support for better pipeline compatibility

  • Loading branch information
kohsuke committed Sep 7, 2017
1 parent 760d831 commit d8fecdcd42fde84fa0e7c18850acfa330fab7941
@@ -53,6 +53,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>structs</artifactId>
<version>1.2</version>
</dependency>
<!-- Used for UI test -->
<dependency>
<groupId>org.jenkins-ci.main</groupId>
@@ -68,6 +68,7 @@
import org.acegisecurity.GrantedAuthority;
import org.acegisecurity.providers.UsernamePasswordAuthenticationToken;
import org.apache.commons.lang.StringUtils;
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.AncestorInPath;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;
@@ -573,7 +574,7 @@ public String resolve(String name) {
return expected.equals(expanded);
}

@Extension
@Extension @Symbol("copyArtifacts")
public static final class DescriptorImpl extends BuildStepDescriptor<Builder> {

public FormValidation doCheckProjectName(
@@ -30,6 +30,7 @@
import jenkins.model.Jenkins;

import org.apache.commons.lang.StringUtils;
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.AncestorInPath;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.QueryParameter;
@@ -178,7 +179,7 @@ protected boolean isSelectable(Run<?, ?> run, EnvVars env) {
return false;
}

@Extension
@Extension @Symbol("downstream")
public static final class DescriptorImpl extends Descriptor<BuildSelector> {
@Override
public String getDisplayName() {
@@ -28,6 +28,8 @@
import hudson.model.Descriptor;
import hudson.model.Result;
import hudson.model.Run;
import jenkins.model.Jenkins;
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;

/**
@@ -44,8 +46,17 @@ public boolean isSelectable(Run<?,?> run, EnvVars env) {
return true;
}

@Extension
public static final Descriptor<BuildSelector> DESCRIPTOR =
new SimpleBuildSelectorDescriptor(
LastCompletedBuildSelector.class, Messages._LastCompletedBuildSelector_DisplayName());
/**
* @deprecated
* here for backward compatibility. Get it from {@link Jenkins#getDescriptor(Class)}
*/
public static /*almost final*/ Descriptor<BuildSelector> DESCRIPTOR;

@Extension @Symbol("lastCompleted")
public static final class DescriptorImpl extends SimpleBuildSelectorDescriptor {
public DescriptorImpl() {
super(LastCompletedBuildSelector.class, Messages._LastCompletedBuildSelector_DisplayName());
DESCRIPTOR = this;
}
}
}
@@ -32,7 +32,9 @@
import hudson.model.Job;
import hudson.model.Run;

import jenkins.model.Jenkins;
import org.apache.commons.lang.StringUtils;
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;

/**
@@ -102,8 +104,17 @@ private String resolveParameter(EnvVars env) {
return xml;
}

@Extension(ordinal=-20)
public static final Descriptor<BuildSelector> DESCRIPTOR =
new SimpleBuildSelectorDescriptor(
ParameterizedBuildSelector.class, Messages._ParameterizedBuildSelector_DisplayName());
/**
* @deprecated
* here for backward compatibility. Get it from {@link Jenkins#getDescriptor(Class)}
*/
public static /*almost final*/ Descriptor<BuildSelector> DESCRIPTOR;

@Extension(ordinal=-20) @Symbol("buildParameter")
public static final class DescriptorImpl extends SimpleBuildSelectorDescriptor {
public DescriptorImpl() {
super(ParameterizedBuildSelector.class, Messages._ParameterizedBuildSelector_DisplayName());
DESCRIPTOR = this;
}
}
}
@@ -32,6 +32,7 @@
import hudson.model.Run;
import hudson.util.ComboBoxModel;
import jenkins.model.Jenkins;
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.AncestorInPath;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.QueryParameter;
@@ -57,7 +58,7 @@ public PermalinkBuildSelector(String id) {
return (run != null && filter.isSelectable(run, env)) ? run : null;
}

@Extension
@Extension @Symbol("permalink")
public static class DescriptorImpl extends Descriptor<BuildSelector> {
@Override
public String getDisplayName() {
@@ -27,6 +27,8 @@
import hudson.Extension;
import hudson.model.Descriptor;
import hudson.model.Run;
import jenkins.model.Jenkins;
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;

/**
@@ -42,8 +44,17 @@ protected boolean isSelectable(Run<?,?> run, EnvVars env) {
return run.isKeepLog();
}

@Extension(ordinal=50)
public static final Descriptor<BuildSelector> DESCRIPTOR =
new SimpleBuildSelectorDescriptor(
SavedBuildSelector.class, Messages._SavedBuildSelector_DisplayName());
/**
* @deprecated
* here for backward compatibility. Get it from {@link Jenkins#getDescriptor(Class)}
*/
public static /*almost final*/ Descriptor<BuildSelector> DESCRIPTOR;

@Extension(ordinal=50) @Symbol("latestSavedBuild")
public static final class DescriptorImpl extends SimpleBuildSelectorDescriptor {
public DescriptorImpl() {
super(SavedBuildSelector.class, Messages._SavedBuildSelector_DisplayName());
DESCRIPTOR = this;
}
}
}
@@ -31,6 +31,9 @@
import hudson.model.Run;
import java.util.logging.Level;
import java.util.logging.Logger;

import jenkins.model.Jenkins;
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;

/**
@@ -94,8 +97,17 @@ public String getBuildNumber() {
return run;
}

@Extension(ordinal=-10)
public static final Descriptor<BuildSelector> DESCRIPTOR =
new SimpleBuildSelectorDescriptor(
SpecificBuildSelector.class, Messages._SpecificBuildSelector_DisplayName());
/**
* @deprecated
* here for backward compatibility. Get it from {@link Jenkins#getDescriptor(Class)}
*/
public static /*almost final*/ Descriptor<BuildSelector> DESCRIPTOR;

@Extension(ordinal=-10) @Symbol("specific")
public static final class DescriptorImpl extends SimpleBuildSelectorDescriptor {
public DescriptorImpl() {
super(SpecificBuildSelector.class, Messages._SpecificBuildSelector_DisplayName());
DESCRIPTOR = this;
}
}
}
@@ -28,7 +28,10 @@
import hudson.model.Descriptor;
import hudson.model.Result;
import hudson.model.Run;
import jenkins.model.Jenkins;
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;

/**
* Copy artifacts from the latest successful or stable build.
@@ -37,11 +40,21 @@
public class StatusBuildSelector extends BuildSelector {
private Boolean stable;

@DataBoundConstructor
@Deprecated
public StatusBuildSelector(boolean stable) {
setStable(stable);
}

@DataBoundConstructor
public StatusBuildSelector() {
}

@DataBoundSetter
public void setStable(boolean stable) {
this.stable = stable ? Boolean.TRUE : null;
}


public boolean isStable() {
return stable != null && stable.booleanValue();
}
@@ -51,8 +64,17 @@ public boolean isSelectable(Run<?,?> run, EnvVars env) {
return isBuildResultBetterOrEqualTo(run, isStable() ? Result.SUCCESS : Result.UNSTABLE);
}

@Extension(ordinal=100)
public static final Descriptor<BuildSelector> DESCRIPTOR =
new SimpleBuildSelectorDescriptor(
StatusBuildSelector.class, Messages._StatusBuildSelector_DisplayName());
/**
* @deprecated
* here for backward compatibility. Get it from {@link Jenkins#getDescriptor(Class)}
*/
public static /*almost final*/ Descriptor<BuildSelector> DESCRIPTOR;

@Extension(ordinal=100) @Symbol("lastSuccessful")
public static final class DescriptorImpl extends SimpleBuildSelectorDescriptor {
public DescriptorImpl() {
super(StatusBuildSelector.class, Messages._StatusBuildSelector_DisplayName());
DESCRIPTOR = this;
}
}
}
@@ -41,6 +41,7 @@
import hudson.model.Run;
import net.sf.json.JSONObject;

import org.jenkinsci.Symbol;
import org.jvnet.localizer.Localizable;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.StaplerRequest;
@@ -218,7 +219,7 @@ protected boolean isSelectable(Run<?,?> run, EnvVars env) {
return isFallbackToLastSuccessful() && isBuildResultBetterOrEqualTo(run, Result.SUCCESS);
}

@Extension(ordinal=25)
@Extension(ordinal=25) @Symbol("upstream")
public static class DescriptorImpl extends SimpleBuildSelectorDescriptor {
private UpstreamFilterStrategy globalUpstreamFilterStrategy;

@@ -31,6 +31,10 @@
import hudson.model.Run;
import java.io.IOException;
import java.io.PrintStream;

import jenkins.model.Jenkins;
import org.jenkinsci.Symbol;
import org.jvnet.localizer.Localizable;
import org.kohsuke.stapler.DataBoundConstructor;

/**
@@ -62,8 +66,17 @@ public boolean isSelectable(Run<?,?> run, EnvVars env) {
}
}

@Extension(ordinal=-20)
public static final Descriptor<BuildSelector> DESCRIPTOR =
new SimpleBuildSelectorDescriptor(
WorkspaceSelector.class, Messages._WorkspaceSelector_DisplayName());
/**
* @deprecated
* here for backward compatibility. Get it from {@link Jenkins#getDescriptor(Class)}
*/
public static /*almost final*/ Descriptor<BuildSelector> DESCRIPTOR;

@Extension(ordinal=-20) @Symbol("workspace")
public static final class DescriptorImpl extends SimpleBuildSelectorDescriptor {
public DescriptorImpl() {
super(WorkspaceSelector.class, Messages._WorkspaceSelector_DisplayName());
DESCRIPTOR = this;
}
}
}

0 comments on commit d8fecdc

Please sign in to comment.