提交 1be0d946 编写于 作者: M mindless

[FIXED HUDSON-324] when starting build via build?token=TOKEN_NAME,

support optional "cause" parameter which adds text into the recorded
RemoteCause.  Also print build cause(s) at start of console output
(instead of just "started").


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@16109 71c3de6d-444a-0410-be80-ed276b4c234a
上级 45450aae
......@@ -1073,7 +1073,9 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
Cause cause;
if (authToken != null && authToken.getToken() != null && req.getParameter("token") != null) {
cause = new RemoteCause(req.getRemoteAddr());
// Optional additional cause text when starting via token
String causeText = req.getParameter("cause");
cause = new RemoteCause(req.getRemoteAddr() + (causeText!=null ? " (" + causeText + ')' : ""));
} else {
cause = new UserCause();
}
......
......@@ -61,13 +61,11 @@ public final class BuildAuthorizationToken {
if (!Hudson.getInstance().isUseSecurity())
return; // everyone is authorized
if(token!=null) {
if(token.token != null) {
//check the provided token
String providedToken = req.getParameter("token");
if (providedToken != null && providedToken.equals(token.token))
return;
}
if(token!=null && token.token != null) {
//check the provided token
String providedToken = req.getParameter("token");
if (providedToken != null && providedToken.equals(token.token))
return;
}
project.checkPermission(AbstractProject.BUILD);
......
......@@ -23,6 +23,8 @@
*/
package hudson.model;
import java.util.List;
/**
* Receives events that happen during a build.
*
......@@ -33,7 +35,7 @@ public interface BuildListener extends TaskListener {
/**
* Called when a build is started.
*/
void started();
void started(List<Cause> causes);
/**
* Called when a build is finished.
......
......@@ -886,7 +886,8 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
this.charset = charset.name();
listener = new StreamBuildListener(new PrintStream(new CloseProofOutputStream(log)),charset);
listener.started();
CauseAction causeAction = getAction(CauseAction.class);
listener.started(causeAction!=null ? causeAction.getCauses() : null);
RunListener.fireStarted(this,listener);
......
......@@ -36,6 +36,7 @@ import java.io.Serializable;
import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
import java.nio.charset.Charset;
import java.util.List;
/**
* {@link BuildListener} that writes to an {@link OutputStream}.
......@@ -65,8 +66,12 @@ public class StreamBuildListener implements BuildListener, Serializable {
charset==null ? new OutputStreamWriter(w) : new OutputStreamWriter(w,charset)), true);
}
public void started() {
w.println("started");
public void started(List<Cause> causes) {
if (causes==null || causes.isEmpty())
w.println("Started");
else for (Cause cause : causes) {
w.println(cause.getShortDescription());
}
}
public PrintStream getLogger() {
......@@ -92,7 +97,7 @@ public class StreamBuildListener implements BuildListener, Serializable {
}
public void finished(Result result) {
w.println("finished: "+result);
w.println("Finished: "+result);
}
......
......@@ -36,7 +36,8 @@ THE SOFTWARE.
<f:textbox name="authToken" value="${it.authToken.token}" />
${%Use the following URL to trigger build remotely:}
<tt>HUDSON_URL</tt>/${it.url}build?token=<tt>TOKEN_NAME</tt>
<br>${%Optionally append &lt;tt>&amp;cause=Cause+Text&lt;/tt> to provide text that will be included in the recorded build cause.}</br>
</f:entry>
</f:optionalBlock>
</j:if>
</j:jelly>
\ No newline at end of file
</j:jelly>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册