Skip to content
Permalink
Browse files
JENKINS-28323: Added special versions RELEASE and LATEST to the versi…
…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 f0035fd9acd1d3aeb20d1ee75e6e3a52ccdcc217
Showing with 12 additions and 8 deletions.
  1. +12 −8 src/main/java/org/jvnet/hudson/plugins/repositoryconnector/VersionParameterDefinition.java
@@ -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;
@@ -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 {

@@ -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 {
@@ -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;
}

0 comments on commit f0035fd

Please sign in to comment.