Skip to content

Commit 3a7342d

Browse files
stevendpclarkValentin Delaye
authored and
Valentin Delaye
committed
[JENKINS-54929] Always flush the output logger on the TaskListener
- Extract the logger out of the TaskListener and pass it to the stdout/stderr methods of the Launcher - Trap all errors and force a flush of the logger once the command has completed
1 parent 431aa39 commit 3a7342d

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/main/java/org/jenkinsci/plugins/ansible/CLIRunner.java

+13-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.jenkinsci.plugins.ansible;
22

33
import java.io.IOException;
4+
import java.io.PrintStream;
45
import java.util.Map;
56

67
import hudson.FilePath;
@@ -42,10 +43,17 @@ public CLIRunner(Run<?, ?> build, FilePath ws, Launcher launcher, TaskListener l
4243
public boolean execute(ArgumentListBuilder args, Map<String, String> environment)
4344
throws IOException, InterruptedException
4445
{
45-
return launcher.launch()
46-
.pwd(ws)
47-
.envs(environment)
48-
.cmds(args)
49-
.stdout(listener).join() == 0;
46+
PrintStream logger = listener.getLogger();
47+
try {
48+
return launcher.launch()
49+
.pwd(ws)
50+
.envs(environment)
51+
.cmds(args)
52+
.stdout(logger)
53+
.stderr(logger).join() == 0;
54+
}
55+
finally {
56+
logger.flush();
57+
}
5058
}
5159
}

0 commit comments

Comments
 (0)