New sonarqube scan is overriding coverage of previous scan though scan is on unique paths

122 Views Asked by At

Team, new sonar scan is deleting coverage of previous scan.

I have Mainrepo that has 10services under one project.

ProjectA has 10Teams and each team has its own product. so structure is like

ProjectA > Team1, Team2, Team10
Team1 = src/services/team1
Team2 = src/services/team2
Team10 = src/services/team10

so my sonar scan everytime it is running is replacing the coverage of previous team. can this be handled that scan is only update and not replace of the code coverage?

sonar properties i have is below

#----- Default SonarQube server
sonar.projectVersion=v1
sonar.branch.name=main
sonar.branch.version=v1
sonar.projectKey=Main_Prod
sonar.projectName=Main
sonar.login=xxxxx
#----- Default source code encoding
#sonar.sourceEncoding=UTF-8

#coverage reports
sonar.python.xunit.reportPath=coverage.xml
sonar.python.coverage.reportPaths=coverage.xml

#Exclusions
# Define the same root directory for sources and tests
sonar.sources = src/
sonar.tests = src/

# Include test subdirectories in test scope
sonar.test.inclusions = src/**/test/**/*

# Exclude test subdirectories from source scope
sonar.exclusions = src/**/test/**/*, src/services/**/*test.*, src/services/**/*.tf
#sonar.exclusions=src/services/**/*.tf
sonar.c.file.suffixes=-
sonar.cpp.file.suffixes=-
sonar.objc.file.suffixes=-

scanner command is this

team_list=("team1","team2","team10")
for team in ${team_list}; do
          generate_coverage($team)
          sonar-scanner \
          -Dsonar.sources=src/services/$team/ \
          -Dsonar.coverageReportPaths=coverage.xml

note: generate_coverage() is a function that creates coverage.xml that is unique per team.

so above loop runs the scans for each team uniquely.

0

There are 0 best solutions below