A couple years ago I was on a project and we had Ansible playbooks running with freestyle Jenkins jobs by using PYTHONUNBUFFERED=1
as an environment variable so that we can see output in realtime, it worked great, it was really useful. Then one day, it stopped working, we tried to fix it but never spent enough time figuring out "what changed" and had other priorities.
I am on another project now with the same technique, only differences are that we have newer Python, Jenkins and Ansible now. I just tried setting PYTHONUNBUFFERED=1
again but no luck, the long running Ansible task that is using the shell module buffers all the output and displays it only after the command has returned.
I have also tried PYTHONBUFFERED=0
, and I tried prefixing the playbook run like PYTHONUNBUFFERED=1 ansible-playbook ...
and also using the pipeline setting environment
to set it and verified with a printenv
but still no luck.
Looking for suggestions on what to try next.
How do I get Jenkins 2.233, Python 2.7.16 and Ansible 2.8.1 to not buffer the output for Ansible shell tasks?
p.s. For reference, other engineers use this technique too: e.g 1. https://coderwall.com/p/d5zqla/unbuffered-output-with-ansible-in-jenkins 2. https://blog.deimos.fr/2016/01/07/ansible-color-and-buffer-fix-on-jenkins/