Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
JENKINS-27641: Made the parameter name configurable. When the propert…
…yName field is left empty, the default property groupId.artifactId=value is set. If the propertyName is set then the parameter propertyName=value will be passed to the build.
  • Loading branch information
mrumpf committed May 12, 2015
1 parent f0035fd commit 8b485b7
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 17 deletions.
Expand Up @@ -29,7 +29,6 @@
import org.sonatype.aether.resolution.VersionRangeResolutionException;
import org.sonatype.aether.version.Version;

@SuppressWarnings("serial")
public class VersionParameterDefinition extends
SimpleParameterDefinition {

Expand All @@ -38,22 +37,24 @@ public class VersionParameterDefinition extends
private final String groupid;
private final String repoid;
private final String artifactid;
private final String propertyName;

@DataBoundConstructor
public VersionParameterDefinition(String repoid, String groupid,
String artifactid, String description) {
String artifactid, String propertyName, String description) {
super(groupid + "." + artifactid, description);
this.repoid = repoid;
this.groupid = groupid;
this.artifactid = artifactid;
this.propertyName = propertyName;
}

@Override
public VersionParameterDefinition copyWithDefaultValue(ParameterValue defaultValue) {
if (defaultValue instanceof StringParameterValue) {
// TODO: StringParameterValue value = (StringParameterValue) defaultValue;
return new VersionParameterDefinition(getRepoid(), "",
"", getDescription());
"", "", getDescription());
} else {
return this;
}
Expand Down Expand Up @@ -100,9 +101,14 @@ public String getGroupid() {
return groupid;
}

@Exported
public String getPropertyName() {
return propertyName;
}

@Override
public ParameterValue createValue(StaplerRequest req, JSONObject jo) {
return new VersionParameterValue(groupid, artifactid, jo.getString("value"));
return new VersionParameterValue(groupid, artifactid, propertyName, jo.getString("value"));
}

@Override
Expand Down
@@ -1,25 +1,22 @@
package org.jvnet.hudson.plugins.repositoryconnector;

import hudson.model.StringParameterValue;
import java.util.logging.Level;

import java.util.logging.Logger;
import org.kohsuke.stapler.DataBoundConstructor;

/**
* This class sets the build parameter as environment value
* "groupid.artifactid=version"
* "groupid.artifactid=version" or as "name=value".
*
* @author mrumpf
*
*/
@SuppressWarnings("serial")
public class VersionParameterValue extends StringParameterValue {

private static final Logger log = Logger
.getLogger(VersionParameterValue.class.getName());

private final String groupid;
private final String artifactid;
private final String propertyName;

public String getGroupid() {
return groupid;
Expand All @@ -29,14 +26,16 @@ public String getArtifactid() {
return artifactid;
}

public String getPropertyName() {
return propertyName;
}

@DataBoundConstructor
public VersionParameterValue(String groupid, String artifactid, String version) {
super(groupid + "." + artifactid, version);
if (log.isLoggable(Level.FINE)) {
log.fine("Creating environment build parameter 'groupid.artifactid=version'");
}
public VersionParameterValue(String groupid, String artifactid, String propertyName, String version) {
super((propertyName != null && !propertyName.isEmpty()) ? propertyName : groupid + "." + artifactid, version);
this.groupid = groupid;
this.artifactid = artifactid;
this.propertyName = propertyName;
}

public String toString() {
Expand All @@ -49,6 +48,8 @@ public String toString() {
sb.append(groupid);
sb.append(", artifactid=");
sb.append(artifactid);
sb.append(", propertyName=");
sb.append(propertyName);
sb.append(']');
return sb.toString();
}
Expand Down
Expand Up @@ -9,6 +9,9 @@
</j:forEach>
</select>
</f:entry>
<f:entry title="${%PropertyName}">
<f:textbox field="propertyName" value="${instance.propertyName}" />
</f:entry>
<f:entry title="${%GroupId}">
<f:textbox field="groupid" value="${instance.groupid}" />
</f:entry>
Expand Down
@@ -1,4 +1,5 @@
Repository=Repository
GroupId=Group Id
ArtifactId=Artifact Id
Description=Description
Description=Description
PropertyName=Property Name
@@ -1,4 +1,5 @@
Repository=Verzeichnis
GroupId=Gruppen Id
ArtifactId=Artefakt Id
Description=Beschreibung
Description=Beschreibung
PropertyName=Attributname

0 comments on commit 8b485b7

Please sign in to comment.