Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-72181] Restore flushed output for 'groovy' CLI command #8622

Merged
merged 2 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/cli/GroovyCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected int run() throws Exception {
final String scriptListenerCorrelationId = String.valueOf(System.identityHashCode(this));

Binding binding = new Binding();
binding.setProperty("out", new ScriptListener.ListenerWriter(new PrintWriter(new OutputStreamWriter(stdout, getClientCharset()), true), GroovyCommand.class, null, scriptListenerCorrelationId, User.current()));
binding.setProperty("out", new PrintWriter(new ScriptListener.ListenerWriter(new OutputStreamWriter(stdout, getClientCharset()), GroovyCommand.class, null, scriptListenerCorrelationId, User.current()), true));
binding.setProperty("stdin", stdin);
binding.setProperty("stdout", stdout);
binding.setProperty("stderr", stderr);
Expand Down
4 changes: 3 additions & 1 deletion test/src/test/java/jenkins/model/ScriptListenerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ public void groovyCliUsageIsLogged() {
logging.record(DefaultScriptListener.class.getName(), Level.FINEST).capture(100);

InputStream scriptStream = new ByteArrayInputStream(script.getBytes());
new CLICommandInvoker(j, "groovy").withArgs("=").withStdin(scriptStream).invoke();
final CLICommandInvoker.Result result = new CLICommandInvoker(j, "groovy").withArgs("=").withStdin(scriptStream).invoke();
final String stdout = result.stdout();
assertThat(stdout, containsString("hello from groovy CLI"));

{ // DefaultScriptListener
final List<String> messages = logging.getMessages();
Expand Down
Loading