[pw-ci] [PATCH 2/2] github_get_logs: handle multiple failed step in a single job

Salvatore Daniele sdaniele at redhat.com
Wed Aug 4 14:18:12 UTC 2021


A github job can fail multiple steps within a single job.
The current implementation fails to pull logs when handed a
job with multiple failed steps.

This patch generates logs for each step of each job.

Signed-off-by: Salvatore Daniele <sdaniele at redhat.com>
---
 github_get_logs.sh | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/github_get_logs.sh b/github_get_logs.sh
index 2f6cc9c..99b60a1 100755
--- a/github_get_logs.sh
+++ b/github_get_logs.sh
@@ -97,28 +97,29 @@ print_errored_logs_for_commit () {
 
     # Print out which jobs failed
     echo "-----------------------Summary of failed steps-----------------------"
-    echo "$jobs_results" | jq -r ".[].name" | while read -r job; do
-        echo "\"$job\" failed at step \"$(echo "$jobs_results" | jq -r ".[] | \
-            select(.name==\"$job\") | .failed_step.name")\""
+        echo "$jobs_results" | jq -r ".[] | .name, .failed_step.name " | while \
+            read -r job && read -r step; do
+        echo "\"$job\" failed at step $step"
     done
     echo "----------------------End summary of failed steps--------------------"
 
     echo ""
     echo "-------------------------------BEGIN LOGS----------------------------"
     spacing=0
+
     # Print out logs for failed jobs
-    echo "$jobs_results" | jq -r ".[].name" | while read -r job; do
+    echo "$jobs_results" | jq -r ".[] | .name, .failed_step.name, .failed_step.number" | while \
+        read -r job && read -r step && read -r log_number; do
+
         if [ ! "$spacing" -eq "0" ]
         then
             echo -ne "\n\n\n\n"
         fi
 
-        step="\"$(echo "$jobs_results" | jq -r ".[] | select(.name==\"$job\") | .failed_step.name")\""
         echo "####################################################################################"
         echo "#### [Begin job log] \"$job\" at step $step"
         echo "####################################################################################"
 
-        log_number=$(echo "$jobs_results" | jq ".[] | select(.name==\"$job\") | .failed_step.number")
         cat "build_logs_series_$series_id/$job/$log_number"_* | tail -n 25 | cut -d' ' -f2- | sed 's/\r$//'
 
         echo "####################################################################################"
-- 
2.31.1



More information about the Pwci mailing list