在我的Jenkins管道中,我启动了一个带有--monitor选项的AWX作业模板,主要目标是能够在Jenkins控制台中跟踪AWX中发生的事情。
sh ("awx --conf.insecure --conf.host ${ansibleUrl} --conf.username ${ANSIBLE_USERNAME} --conf.password ${ANSIBLE_PASSWORD} job_templates launch --extra_vars @ansible_extra_vars_file.json --monitor $ANSIBLE_JOB_TEMPLATE_ID ")一个类似的post about running an ansible playbook via a shell script in jenkins pipeline已经被制造出来了。然而,提出的解决方案没有解决我的pb,因为我没有设置returnStdout: true。
仅当Ansible作业完成时,日志才会显示在Jenkins日志控制台中。
当我直接从Jenkins从服务器启动"awx job_templates launch“命令时,日志会实时显示在stdout中。
如何在Jenkins日志控制台中实时更新stdout?
发布于 2021-01-13 00:14:16
实际上,答案就在这篇关于Jenkins console output not in realtime的文章中
awxkit包是用Python语言编写的,我只需要设置PYTHONUNBUFFERED=1
sh ("export PYTHONUNBUFFERED=1; awx --conf.insecure --conf.host ${ansibleUrl} --conf.username ${ANSIBLE_USERNAME} --conf.password ${ANSIBLE_PASSWORD} job_templates launch --extra_vars @ansible_extra_vars_file.json --monitor $ANSIBLE_JOB_TEMPLATE_ID ")这使我能够在我的Jenkins控制台中实时获取AWX日志。
https://stackoverflow.com/questions/65686997
复制相似问题