jenkinstcsh

Jenkins sh returnstdout returns empty but prints


In my pipeline Im trying to compare the results of 2 sh commands: To run the sh command I added:

def some_var = "empty2"
some_var = sh(returnStdout: true, returnStatus :false, script: """some command""").trim()

In my pipeline log I see the output as expected from the command (long 100s of lines). However when printing the value of some_var it is always empty.

I tried replacing the sh command with an echo, and that seemed to work as expected (variable got the value of the command).

How is it possible that I can see the output in my pipeline, but it is not assigned to my variable.

edit:

I checked the output is about 512 lines, 23190 chars the limit of groovy should be 65535 characters. note im also not getting any assignment errors.

The step is green, indicating there is no fail/error ?

The shell jenkins is using is /bin/tcsh


Solution

  • In bash like shells you can add 2>&1 to your command to redirect stderr to stdout.

    In csh like shells (including tcsh) adding >& /dev/stdout should work if you have /dev/stdout defined. If not - you can try |& cat