Index: build/unittest.sh =================================================================== diff -u -rc32e05b36f9614d2b1db8a1d2f866cd89914bc1d -r5e419961a21fb3206b6fe79833cd7035912ef655 --- build/unittest.sh (.../unittest.sh) (revision c32e05b36f9614d2b1db8a1d2f866cd89914bc1d) +++ build/unittest.sh (.../unittest.sh) (revision 5e419961a21fb3206b6fe79833cd7035912ef655) @@ -524,6 +524,9 @@ echo "Sonar created file: $reportAddress" # Copy the created SonarQube file from the sonar server to the remote directory sshpass -f /opt/sonarQubeServerPass scp dnavaei@192.168.10.41:"$reportAddress" "$REPORT_DIR" + # Replace the extension of the report address from .docx to .md. There is a .md file of the status report that has the + # same name as the docx. The report file with the .md is copied into the remote directory to parse for pass/fail of + # the SonarQube report reportAddress=${reportAddress/.docx/.md} sshpass -f /opt/sonarQubeServerPass scp dnavaei@192.168.10.41:"$reportAddress" "$REPORT_DIR" @@ -538,25 +541,28 @@ sshpass -f /opt/sonarQubeServerPass scp dnavaei@192.168.10.41:"$reportAddress" "$REPORT_DIR" reportAddress=${reportAddress/.docx/.md} sshpass -f /opt/sonarQubeServerPass scp dnavaei@192.168.10.41:"$reportAddress" "$REPORT_DIR" - + # In the remote build directory look for all the files with .md and place them into an array mapfile -t nameOfReports < <(find "$REPORT_DIR" -type f -iname "*.md") - echo "FILES ${nameOfReports[@]}, $REPORT_DIR" for report in "${nameOfReports[@]}" do + # Loop through the list and search for | Quality Gate Status | ERROR | + # Based on the filename (UI manual run and Cloudsync run) write the results into the report file + # Once done with reading the .md file, remove it echo "This file was found: $report" local status="" local sonarStatus=$(grep "| Quality Gate Status | ERROR |" "$report") if [[ -z "$sonarStatus" ]]; then status="Passed"; else status="Failed"; fi if [[ "$report" == *"$sonarRunUIProject"* ]] then - echo co "UI SonarQube Result:,$status" >> "$STATUS_REPORT" + echo "UI SonarQube Result:,$status" >> "$STATUS_REPORT" elif [[ "$report" == *"$sonarRunCloudSyncProject"* ]] then echo "Cloudsync SonarQube Result:,$status" >> "$STATUS_REPORT" fi + echo co "" >> "$STATUS_REPORT" + rm -rf "$report" done - # Done with the sonar operations, go back to the upper address cd "$currentDir" || return }