I am using Sonar Developer Edition version 8.4.1.
I am confused on how best to use the -Dsonar.projectVersion scanner option in GitLab CI. I would like to use the last commit short sha to our Master branch as the version. So, the new code period should be set to any code since that last Master commit. I really am lost trying to find the best way to do this since Developer edition has branch analysis and merge request support. The code bases are primarily Go, Python, and NodeJS.
I tried a bit of code where we configure the scanner options in CI:
if [[ "$CI_COMMIT_BRANCH" == master ]] || [[ "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" == master ]]; then COMMAND="$COMMAND -Dsonar.projectVersion=$CI_COMMIT_SHORT_SHA" fi
But I am not getting the results as I would expect, I only see “Master” in the activity. And most of the project’s new code period is not getting any version at all.
Has anyone setup versioning in a similar matter in GitlabCI? Or any best practices for setting up versions with branches, etc?