Pipeline bat stdout redirection

1,531 views
Skip to first unread message

jer...@bodycad.com

unread,
Aug 25, 2016, 1:54:34 PM8/25/16
to Jenkins Users
Hi,
I have a problem when executing some batch script with python, everything work fine except when python try to run a subprocess.Popen() where the stdout and stderr doesn't seem to show into the console and cannot even PIPE them! they are eaten by something. The print from that script display normally however?!

If I run the Python script form command line the output is normally displayed for both subprocess and print.

So I suspect the pipeline is doing some kind of redirection of the stdout and stderr that is not clean and the subprocess spawn is not aware of that and get all messup.

Anybody know what is going on?

as for why I do Python script, my tooling was made into python and have many issue with groovy into JenkinsFile and iterator to still avoid porting right now.

Thanks
Jerome 

jer...@bodycad.com

unread,
Aug 25, 2016, 2:43:43 PM8/25/16
to Jenkins Users
This is really weird, even making the subprocess.Popen redirect out and error to a file the content is empty inside Jenkinsfile script only. Running the same script with the same cwd and same parameters from a console work normaly. 
Also try to set sys.stdout = sys.__stdout__ just to make sure, but I guess the stdout is already mess up with!?!

jer...@bodycad.com

unread,
Aug 25, 2016, 3:05:36 PM8/25/16
to Jenkins Users
I tried to execute the 
def out_str = bat([returnStdout:true, script:"..."]);
println out_str
;
without any luck, still have the same result. That's sad, why does normal print succeed, the Subprocess are run, and the proper return code is returned for each subprocess indicating they are running and completing properly into Python but the stdout and stderr aren't working or seem to be empty!?!? like if something is flushing/rdirecting them into something else.

JAY D SHAH

unread,
Oct 10, 2018, 5:49:29 AM10/10/18
to Jenkins Users
I am Facing the same issue, Does anyone got something on it

For me, Std_err gets called by Clean_up With Jenkins file due to which I can't get the correct error message

Reply all
Reply to author
Forward
0 new messages