@@ -66,6 +66,8 @@ parse_output ()
6666}
6767
6868analyze_logs_by_logdetective () {
69+ # logdetective should not break the build functionality
70+ set +e
6971 local log_file_name=" $1 "
7072 echo " Sending failed log by fpaste command to paste bin."
7173 paste_bin_link=$( fpaste " $log_file_name " )
@@ -79,14 +81,26 @@ analyze_logs_by_logdetective() {
7981 raw_paste_bin_link=" ${paste_bin_link// view/ view\/ raw} "
8082 echo " Sending log file to logdetective server: ${raw_paste_bin_link} "
8183 echo " -------- LOGDETECTIVE BUILD LOG ANALYSIS START --------"
84+ logdetective_build_file=$( mktemp " /tmp/logdetective_build.XXXXXX" )
8285 # 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
8487 echo " ERROR: Failed to analyze log file by logdetective server."
85- cat " /tmp/logdetective_output.txt "
88+ cat " ${logdetective_build_file} "
8689 echo " -------- LOGDETECTIVE BUILD LOG ANALYSIS FAILED --------"
90+ set -e
8791 return
8892 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 '."
90104 echo " -------- LOGDETECTIVE BUILD LOG ANALYSIS FINISHED --------"
91105}
92106
0 commit comments