Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

In my Jenkins pipeline, I launch a AWX job template with the option --monitor, the main goal being able to follow in Jenkins console what's going on in 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  ")

A similar post about running an ansible playbook via a shell script in jenkins pipeline had been made. However, the solution proposed does not solve my pb as I did not set returnStdout: true anyway.

The log is displayed in the Jenkins log console only when the Ansible job is completed.

When I launch the "awx job_templates launch" command directly from the Jenkins slave, the log is displayed in real time in the stdout.

How can I have the stdout being updated in real time in the Jenkins log console ?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
2.5k views
Welcome To Ask or Share your Answers For Others

1 Answer

Actually, the answer was somehow in this post about Jenkins console output not in realtime

The awxkit package being coded in Python, I just needed to set 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  ")

This allowed me to obtain the AWX logs in real time in my Jenkins console.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...