Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[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 1409fdf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
3 changes: 3 additions & 0 deletions changelog.html
Expand Up @@ -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.
Expand Down
Expand Up @@ -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.
Expand Down Expand Up @@ -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(".");
}
}

/**
Expand Down

0 comments on commit 1409fdf

Please sign in to comment.