On 23/10/14 18:17, cchen wrote:
Hey folks,

In a plugin, I need to execute a command, print command output to the
build log in real time and return the command output to the caller.

First, I tried the following, but the problems is that there is no way
to save command output.

    ProcStarter =
    launcher.launch().cmds(args).envs(environment).pwd(workDir);

    int status = proc.stdout(launcher.getListener().getLogger()).join();

Second, I tried

    ProcStarter =
    launcher.launch().cmds(args).envs(environment).pwd(workDir);

    ByteArrayOutputStream fos = newByteArrayOutputStream();

    int status = proc.stdout(fos).join();

But there is no way for me to print the cmd output to the build log in
real time.

Any suggestions?

Create a ForkOutputStream with the logger and your byte array stream:
http://javadoc.jenkins-ci.org/byShortName/ForkOutputStream

--
You received this message because you are subscribed to the Google Groups "Jenkins 
Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to