Skip to content
Permalink
Browse files
Change JIRA issue parameter to name/value to conform to standard and …
…expose the value via API.

JENKINS-12578 JENKINS-25828
  • Loading branch information
Radosław Antoniuk committed Oct 29, 2015
1 parent d95df0f commit 0100428a5528e7aefd99a1800cedd66441547110
@@ -230,7 +230,7 @@ protected JiraSession createSession() throws IOException {
LOGGER.warning("convert URL to URI error: " + e.getMessage());
throw new RuntimeException("failed to create JiraSession due to convert URI error");
}
LOGGER.info("creating Jira Session: " + uri);
LOGGER.fine("creating Jira Session: " + uri);

final JiraRestClient jiraRestClient = new AsynchronousJiraRestClientFactory()
.createWithBasicHttpAuthentication(uri, userName, password.getPlainText());
@@ -341,7 +341,7 @@ static void findIssues(AbstractBuild<?, ?> build, Set<String> ids, Pattern patte
if (parameters != null) {
for (ParameterValue val : parameters.getParameters()) {
if (val instanceof JiraIssueParameterValue) {
ids.add(((JiraIssueParameterValue) val).getIssue());
ids.add(((JiraIssueParameterValue) val).getValue());
}
}
}
@@ -18,46 +18,48 @@
import hudson.EnvVars;
import hudson.model.AbstractBuild;
import hudson.model.ParameterValue;
import hudson.model.Run;
import hudson.util.VariableResolver;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.export.Exported;

public class JiraIssueParameterValue extends ParameterValue {
private static final long serialVersionUID = -1078274709338167211L;

private String issue;
private String value;

@DataBoundConstructor
public JiraIssueParameterValue(final String name, final String issue) {
public JiraIssueParameterValue(final String name, final String value) {
super(name);
this.issue = issue;
this.value = value;
}

@Override
public void buildEnvVars(final AbstractBuild<?, ?> build, final EnvVars env) {
env.put(getName(), getIssue());
public void buildEnvironment(final Run<?, ?> run, final EnvVars env) {
env.put(getName(), getValue());
}

@Override
public VariableResolver<String> createVariableResolver(
final AbstractBuild<?, ?> build) {
return new VariableResolver<String>() {
public String resolve(final String name) {
return JiraIssueParameterValue.this.name.equals(name) ? getIssue()
: null;
return JiraIssueParameterValue.this.name.equals(name) ? getValue() : null;
}
};
}

public void setIssue(final String issue) {
this.issue = issue;
public void setValue(final String value) {
this.value = value;
}

public String getIssue() {
return issue;
@Exported
public String getValue() {
return value;
}

@Override
public String toString() {
return "(JiraIssueParameterValue) " + getName() + "='" + issue + "'";
return "(JiraIssueParameterValue) " + getName() + "='" + value + "'";
}
}
@@ -32,8 +32,7 @@ public VariableResolver<String> createVariableResolver(
final AbstractBuild<?, ?> build) {
return new VariableResolver<String>() {
public String resolve(final String name) {
return JiraVersionParameterValue.this.name.equals(name) ? getVersion()
: null;
return JiraVersionParameterValue.this.name.equals(name) ? getVersion() : null;
}
};
}
@@ -27,7 +27,7 @@ limitations under the License.
</j:when>
<j:otherwise>
<!-- everything is fine, we can display the drop-down list to the user -->
<select name="issue">
<select name="value">
<j:forEach var="issue" items="${it.issues}">
<option value="${issue.key}">${issue.key}: ${issue.summary}</option>
</j:forEach>

0 comments on commit 0100428

Please sign in to comment.