From 33735a490de11d8b9ac107e93470ecfe52c74e52 Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Tue, 24 Jul 2012 15:49:35 -0400 Subject: [PATCH] When overriding UserIdCause.getShortDescription, you need to override print as well. Noticed via failure in BuildCommandTest.testConsoleOutput. https://github.com/jenkinsci/jenkins/pull/522 --- core/src/main/java/hudson/cli/BuildCommand.java | 8 ++++++++ test/src/test/groovy/hudson/cli/BuildCommandTest.groovy | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/hudson/cli/BuildCommand.java b/core/src/main/java/hudson/cli/BuildCommand.java index 6f9cf2dae4..16591e916a 100644 --- a/core/src/main/java/hudson/cli/BuildCommand.java +++ b/core/src/main/java/hudson/cli/BuildCommand.java @@ -32,7 +32,9 @@ import hudson.model.ParametersDefinitionProperty; import hudson.model.ParameterDefinition; import hudson.Extension; import hudson.AbortException; +import hudson.console.ModelHyperlinkNote; import hudson.model.Item; +import hudson.model.TaskListener; import hudson.model.queue.QueueTaskFuture; import hudson.scm.PollingResult.Change; import hudson.util.EditDistance; @@ -158,6 +160,12 @@ public class BuildCommand extends CLICommand { return "Started by command line by " + startedBy; } + @Override + public void print(TaskListener listener) { + listener.getLogger().println("Started by command line by " + + ModelHyperlinkNote.encodeTo("/user/"+getUserId(), getUserName())); + } + @Override public boolean equals(Object o) { return o instanceof CLICause; diff --git a/test/src/test/groovy/hudson/cli/BuildCommandTest.groovy b/test/src/test/groovy/hudson/cli/BuildCommandTest.groovy index 16eace5242..aeea843a49 100644 --- a/test/src/test/groovy/hudson/cli/BuildCommandTest.groovy +++ b/test/src/test/groovy/hudson/cli/BuildCommandTest.groovy @@ -105,7 +105,7 @@ public class BuildCommandTest extends HudsonTestCase { def o = new ByteArrayOutputStream() cli.execute(["build","-s","-v",p.name],System.in,new TeeOutputStream(System.out,o),System.err) assertBuildStatusSuccess(p.getBuildByNumber(1)) - assertTrue(o.toString().contains("Started by command line by anonymous")) + assertTrue(o.toString(), o.toString().contains("Started by command line by anonymous")) assertTrue(o.toString().contains("Finished: SUCCESS")) } finally { cli.close() -- GitLab