-1

So I have Jenkins agent running on a Windows Server over SSH.

If I run a programm with some arguments on the powershell on the server:

.\PVITransfer.exe -consoleOutput -automatic -"test.pil"

I get the desired output.

If I run the same comand in Jenkins I get no output. What am I doing wrong?

1 Answer 1

0

You should redirect the output of the command. When you're running the program interactively, your console is receiving the console output.

However, when you use other tools to dispatch commands, you're beholden to however they capture output. Well as it turns out in Windows there are a number of different streams of messages that all write out to the console window, including Informational, Console, Warning and Error streams.

You can redirect the output of your command into the standard info stream, which is probably what Jenkins is capturing, by just appending this to the end of your commands, like this:

*>&1 

This will tell PowerShell to redirect all output into the standard success stream, stream 1, and will likely solve your issue.

Here's some more reading on the topic, it definitely trips up everyone at least two times.

https://devblogs.microsoft.com/scripting/understanding-streams-redirection-and-write-host-in-powershell/

https://www.koskila.net/how-to-redirect-console-output-to-a-file/#:~:text=How%20to%20redirect%20console%20or%20PowerShell%20output%20to,worked%20%28optional%29%20...%203%20And%20that%E2%80%99s%20it%21%20

2
  • Well it's not working i tried: .\PVITransfer.exe -consoleOutput -automatic -"test.pil" *>&1 . without geting any output. The thing is -consoleOutput redirects the output to the calling console and it works just fine localy on the server. Just when using jenkins to run this command remotly I lose all output.
    – Moone
    Feb 27 at 15:54
  • Jenkins creates in Freestyle Projects .bat files and runs them, coud this be the reason i am not getting the output? If so is there a way to get the output?
    – Moone
    Feb 28 at 11:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.