Skip to content
Permalink
Browse files

[FIXED JENKINS-13546]: return a JSON string when client request it th…

…rough content-type header

When a client uses the buildWithParameters API and request a json output, return the job definition as a json string instead of doing a redirect on the job page.
  • Loading branch information
rborer authored and kohsuke committed Apr 26, 2012
1 parent 7dff954 commit 1409fdff1955581b91904d73781054a63f1d6f85
Showing with 12 additions and 3 deletions.
  1. +3 −0 changelog.html
  2. +9 −3 core/src/main/java/hudson/model/ParametersDefinitionProperty.java
@@ -66,6 +66,9 @@
<li class=rfe>
PAM authentication supports '@group' to force interpretation as a group instead of user.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-13526">issue 13526</a>)
<li class=rfe>
Honor the <tt>Accept</tt> header in the <tt>job/name/build</tt> URL.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-13546">issue 13546</a>)
<li class=rfe>
Added a DISCOVER permission to allow anonymous users to be presented the login screen
when accessing job URLs.
@@ -44,6 +44,7 @@
import org.kohsuke.stapler.export.ExportedBean;

import hudson.Extension;
import org.kohsuke.stapler.export.Flavor;

/**
* Keeps a list of the parameters defined for a project.
@@ -144,11 +145,16 @@ public void buildWithParameters(StaplerRequest req, StaplerResponse rsp) throws
}
}

Jenkins.getInstance().getQueue().schedule(
Jenkins.getInstance().getQueue().schedule(
owner, owner.getDelay(req), new ParametersAction(values), owner.getBuildCause(req));

// send the user back to the job top page.
rsp.sendRedirect(".");
if (req.getContentType() != null && req.getContentType().contains("application/json")) {
rsp.setContentType("application/json");
rsp.serveExposedBean(req, owner, Flavor.JSON);
} else {
// send the user back to the job top page.
rsp.sendRedirect(".");
}
}

/**

0 comments on commit 1409fdf

Please sign in to comment.