add log logic to cd
This commit is contained in:
parent
cd7b0743b6
commit
c7a98bcf02
1 changed files with 28 additions and 15 deletions
|
@ -94,20 +94,33 @@ jobs:
|
||||||
"https://awx.mafyuh.xyz/api/v2/job_templates/13/launch/" > /dev/null 2>&1
|
"https://awx.mafyuh.xyz/api/v2/job_templates/13/launch/" > /dev/null 2>&1
|
||||||
echo "AWX Job Triggered, waiting for logs..."
|
echo "AWX Job Triggered, waiting for logs..."
|
||||||
|
|
||||||
sleep 45
|
# Wait for job completion and check logs
|
||||||
|
while true; do
|
||||||
|
# Fetch the most recent job ID
|
||||||
|
job_id=$(curl -s -H "Authorization: Bearer ${{ secrets.AWX_API_TOKEN }}" \
|
||||||
|
https://awx.mafyuh.xyz/api/v2/job_templates/13/jobs/?order_by=-id | jq -r '.results[0].id')
|
||||||
|
|
||||||
|
# Fetch the logs for the current job
|
||||||
|
logs=$(curl -s -H "Authorization: Bearer ${{ secrets.AWX_API_TOKEN }}" \
|
||||||
|
https://awx.mafyuh.xyz/api/v2/jobs/$job_id/stdout/?format=txt)
|
||||||
|
|
||||||
job_id=$(curl -s -H "Authorization: Bearer ${{ secrets.AWX_API_TOKEN }}" https://awx.mafyuh.xyz/api/v2/job_templates/13/jobs/?order_by=-id | jq -r '.results[0].id')
|
# Check if the logs contain the play recap
|
||||||
logs=$(curl -s -H "Authorization: Bearer ${{ secrets.AWX_API_TOKEN }}" https://awx.mafyuh.xyz/api/v2/jobs/$job_id/stdout/?format=txt)
|
if echo "$logs" | grep -q "ok=.* changed=.* unreachable=.* failed=.* skipped=.* rescued=.* ignored=.*"; then
|
||||||
|
echo "AWX job completed. Displaying logs:"
|
||||||
|
echo "$logs"
|
||||||
|
|
||||||
|
# Check for failed tasks in the play recap
|
||||||
|
if echo "$logs" | grep -q "failed=[1-9]"; then
|
||||||
|
echo "Detected failed steps in AWX job. Failing Actions run."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "No failures detected in AWX job."
|
||||||
|
fi
|
||||||
|
|
||||||
echo "AWX Job Logs for folder: $folder"
|
# Exit loop as the job is complete
|
||||||
echo "Content:"
|
break
|
||||||
echo "$logs"
|
else
|
||||||
|
echo "AWX job still running. Waiting before checking again..."
|
||||||
# Check for 'failed=' in the play recap
|
sleep 15
|
||||||
if echo "$logs" | grep -q "failed=[1-9]"; then
|
fi
|
||||||
echo "Detected failed steps in AWX job. Failing Actions run."
|
done
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
echo "No failures detected in AWX job."
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
Loading…
Reference in a new issue