@@ -66,6 +66,8 @@ parse_output ()
66
66
}
67
67
68
68
analyze_logs_by_logdetective () {
69
+ # logdetective should not break the build functionality
70
+ set +e
69
71
local log_file_name=" $1 "
70
72
echo " Sending failed log by fpaste command to paste bin."
71
73
paste_bin_link=$( fpaste " $log_file_name " )
@@ -79,14 +81,26 @@ analyze_logs_by_logdetective() {
79
81
raw_paste_bin_link=" ${paste_bin_link// view/ view\/ raw} "
80
82
echo " Sending log file to logdetective server: ${raw_paste_bin_link} "
81
83
echo " -------- LOGDETECTIVE BUILD LOG ANALYSIS START --------"
84
+ logdetective_build_file=$( mktemp " /tmp/logdetective_build.XXXXXX" )
82
85
# shellcheck disable=SC2181
83
- if ! curl -k --insecure --header " Content-Type: application/json" --request POST --data " {\" url\" :\" ${raw_paste_bin_link} \" }" " $LOGDETECTIVE_SERVER /analyze" > /tmp/logdetective_output.txt ; then
86
+ if ! curl -k --insecure --header " Content-Type: application/json" --request POST --data " {\" url\" :\" ${raw_paste_bin_link} \" }" " $LOGDETECTIVE_SERVER /analyze" >> " ${logdetective_build_file} " ; then
84
87
echo " ERROR: Failed to analyze log file by logdetective server."
85
- cat " /tmp/logdetective_output.txt "
88
+ cat " ${logdetective_build_file} "
86
89
echo " -------- LOGDETECTIVE BUILD LOG ANALYSIS FAILED --------"
90
+ set -e
87
91
return
88
92
fi
89
- jq -rC ' .explanation.text' < " /tmp/logdetective_output.txt"
93
+ set -e
94
+ jq -rC ' .explanation.text' < " ${logdetective_build_file} "
95
+ # This part of code is from https://github.com/teemtee/tmt/blob/main/tmt/steps/scripts/tmt-file-submit
96
+ if [ -z " $TMT_TEST_PIDFILE " ]; then
97
+ echo " File submit to data dir can be used only in the context of a running test."
98
+ return
99
+ fi
100
+ # This variable is set by tmt
101
+ [ -d " $TMT_TEST_DATA " ] || mkdir -p " $TMT_TEST_DATA "
102
+ cp -f " ${logdetective_build_file} " " $TMT_TEST_DATA "
103
+ echo " File '${logdetective_build_file} ' stored to '$TMT_TEST_DATA '."
90
104
echo " -------- LOGDETECTIVE BUILD LOG ANALYSIS FINISHED --------"
91
105
}
92
106
0 commit comments