Hi, in this article you will learn about how to fix the Jenkins console output. Whenever you run a python script using a server it is obvious that it doesn't display any console output. it keeps hung at the Python command and after the python script gets executed completely. The output is printed in one shot.
So let's try to fix the above Python and Jenkins issue.
Quick Fix
=====================
When you just type python --help you get the help message from python where it displays the -u option. The help message of -u displays some thing like as shown below
-u : force the stdout and stderr streams to be unbuffered; this option has no effect on stdin; also PYTHONUNBUFFERED=x
The -u option when used while running the python script in Jenkins will allow you to display the script execution output during the runtime.
Modification
=====================
You should provide the argument -u at Execute shell Jenkins Configure section as shown below
python -u script.py ${hostname} ${username} ${password}
Instead of just using
python script.py ${hostname} ${username} ${password}
After using the -u option then try building the Jenkins Job
Now after you build the job you can see that the Python script output gets displayed as the script gets executed.
Conclusion
=================
Just use the -u option while you are using the Jenkins with Python script, this will not buffer the output and print the output to the console during the runtime.
0 Comments