Skip to content

Commit

Permalink
JENKINS-28323: Added special versions RELEASE and LATEST to the versi…
Browse files Browse the repository at this point in the history
…on selection dropdown list (incl. order reversal to make the later versions appear on top of the list)
  • Loading branch information
mrumpf committed May 12, 2015
1 parent a75b5e6 commit f0035fd
Showing 1 changed file with 12 additions and 8 deletions.
Expand Up @@ -5,11 +5,12 @@
import hudson.model.SimpleParameterDefinition;
import hudson.model.StringParameterValue;
import hudson.util.FormValidation;
import java.io.File;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
Expand All @@ -19,20 +20,16 @@
import net.sf.json.JSONArray;
import net.sf.json.JSONException;
import net.sf.json.JSONObject;
import org.jvnet.hudson.plugins.repositoryconnector.aether.Aether;

import org.jvnet.hudson.plugins.repositoryconnector.aether.Aether;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.export.Exported;
import org.sonatype.aether.resolution.VersionRangeResolutionException;
import org.sonatype.aether.version.Version;

/**
*
* @author mrumpf
*
*/
@SuppressWarnings("serial")
public class VersionParameterDefinition extends
SimpleParameterDefinition {

Expand All @@ -54,7 +51,7 @@ public VersionParameterDefinition(String repoid, String groupid,
@Override
public VersionParameterDefinition copyWithDefaultValue(ParameterValue defaultValue) {
if (defaultValue instanceof StringParameterValue) {
StringParameterValue value = (StringParameterValue) defaultValue;
// TODO: StringParameterValue value = (StringParameterValue) defaultValue;
return new VersionParameterDefinition(getRepoid(), "",
"", getDescription());
} else {
Expand All @@ -77,6 +74,13 @@ public List<String> getChoices() {
} catch (VersionRangeResolutionException ex) {
log.log(Level.SEVERE, "Could not determine versions", ex);
}
if (!versionStrings.isEmpty()) {
// reverseorder to have the latest versions on top of the list
Collections.reverse(versionStrings);
// add the default parameters
versionStrings.add(0, "LATEST");
versionStrings.add(0, "RELEASE");
}
}
return versionStrings;
}
Expand Down

0 comments on commit f0035fd

Please sign in to comment.