Index: build/unittest.sh =================================================================== diff -u -ra2296c8111143737fcba7c0f2d173a3e72a906f7 -rb28c3bf15c9cc18ba4ee4d9b2f365bc058790124 --- build/unittest.sh (.../unittest.sh) (revision a2296c8111143737fcba7c0f2d173a3e72a906f7) +++ build/unittest.sh (.../unittest.sh) (revision b28c3bf15c9cc18ba4ee4d9b2f365bc058790124) @@ -438,6 +438,7 @@ local sonarRunUIProject="UI-manualrun" local sonarRunCloudSyncProject="UI_Cloudsync-manualrun" local inlineScriptForReport="sonarReportGeneration.sh" + local headTagOrCommit="" echo " ------------------------------ Running SonarQube test" # Make a folder for SonarQube operations mkdir "$sonarFolder" @@ -451,6 +452,9 @@ # Create a log file and inline shell script touch "$sonarLogs" touch "$inlineScriptForReport" + headTagOrCommit=$(git describe --exact-match HEAD) + echo "UI head: $headTagOrCommit" + if [[ -z "$headTagOrCommit" ]]; then headTagOrCommit=$(git rev-parse HEAD); fi # The inline shell script is created here and is copied into the Sonar server and run the report. Set the script as # executable chmod +x "$inlineScriptForReport" @@ -468,9 +472,13 @@ /opt/sonar-scanner-4.8.0.2856-linux/bin/sonar-scanner -Dsonar.projectKey="$sonarRunUIProject" -Dsonar.sources=. \ -Dsonar.cfamily.build-wrapper-output=. \ -Dsonar.cfamily.threads=4 -Dsonar.host.url=http://192.168.10.41:9000 \ - -Dsonar.login=admin -Dsonar.password="$(head -n 1 /opt/sonarQubeServerPass)" | tee -a "$sonarLogs" + -Dsonar.login=admin -Dsonar.password="$(head -n 1 /opt/sonarQubeServerPass)" \ + -Dsonar.projectVersion="$headTagOrCommit" | tee -a "$sonarLogs" cd ../cloudsync || return + headTagOrCommit=$(git describe --exact-match HEAD) + echo "Cloud head: $headTagOrCommit" + if [[ -z "$headTagOrCommit" ]]; then headTagOrCommit=$(git rev-parse HEAD); fi # Copy the created build wrapper json file into the application folder cp "$currentDir"/"$sonarFolder"/"$buildWrapperJson"/build-wrapper-dump.json "$(pwd)" # Run sonar command. The password is located in the /opt/ folder in the build server and for the password open that @@ -479,8 +487,8 @@ -Dsonar.sources=. \ -Dsonar.cfamily.build-wrapper-output=. \ -Dsonar.cfamily.threads=4 -Dsonar.host.url=http://192.168.10.41:9000 \ - -Dsonar.login=admin -Dsonar.password="$(head -n 1 /opt/sonarQubeServerPass)" | tee -a "$sonarLogs" - + -Dsonar.login=admin -Dsonar.password="$(head -n 1 /opt/sonarQubeServerPass)" \ + -Dsonar.projectVersion="$headTagOrCommit" | tee -a "$sonarLogs" # Copy the sonar logs into the remote build directory cp -r "$sonarLogs" "$REPORT_DIR" @@ -503,7 +511,7 @@ echo 'docxFile=$(find $(pwd) -name "*.docx" | grep "$latestRunDate-$1")' >> "$inlineScriptForReport" # shellcheck disable=SC2016 echo 'echo $docxFile' >> "$inlineScriptForReport" - + # UI project # Copy the created script into the Sonar server. Use sshpass -f to get the password from the file sshpass -f /opt/sonarQubeServerPass scp "$(pwd)/$inlineScriptForReport" dnavaei@192.168.10.41:~/