提交 680dd4a2 编写于 作者: K Kohsuke Kawaguchi

[FIXED JENKINS-13546]

Bringing this to the parity with ParameterizedJobMixIn.doBuild()

Instead of returning JSON, it returns "201 Created" and responds with the location of the queue item, through which the caller can track how it passes through the queue and eventually gets built/cancelled.

The approach in pull request #750 that relies on
AbstractProject.getQueueItem() is inherently unreliable, because
item can be immediately built before the JSON is rendered, or it might
corresponds to other queued items if the build supports concurrent
builds, etc.
上级 5e9d59c6
......@@ -122,7 +122,7 @@ public class ParametersDefinitionProperty extends JobProperty<Job<?, ?>>
/** @deprecated use {@link #_doBuild(StaplerRequest, StaplerResponse, TimeDuration)} */
@Deprecated
public void _doBuild(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
_doBuild(req,rsp,TimeDuration.fromString(req.getParameter("delay")));
_doBuild(req, rsp, TimeDuration.fromString(req.getParameter("delay")));
}
/**
......@@ -179,14 +179,12 @@ public class ParametersDefinitionProperty extends JobProperty<Job<?, ?>>
}
if (delay==null) delay=new TimeDuration(getJob().getQuietPeriod());
Jenkins.getInstance().getQueue().schedule(
getJob(), delay.getTime(), new ParametersAction(values), ParameterizedJobMixIn.getBuildCause(getJob(), req));
Queue.Item item = Jenkins.getInstance().getQueue().schedule2(
getJob(), delay.getTime(), new ParametersAction(values), ParameterizedJobMixIn.getBuildCause(getJob(), req)).getItem();
if (requestWantsJson(req)) {
rsp.setContentType("application/json");
rsp.serveExposedBean(req, owner, Flavor.JSON);
if (item != null) {
rsp.sendRedirect(SC_CREATED, req.getContextPath() + '/' + item.getUrl());
} else {
// send the user back to the job top page.
rsp.sendRedirect(".");
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册