Same pom.xml for differenet projects

Hi I’ve one pom.xml for multiple projects,
For first I’m using this

stage('SonarQube analysis') {
        withSonarQubeEnv('Sonarqube') {
            sh 'sudo cp -r /data/automation/online/platformreports-qa1.moglilabs.com/config ${WORKSPACE}/reports/src/main/resources/config/'
            sh 'cd ${WORKSPACE}/ && mvn clean package sonar:sonar -Dmaven.test.skip=true -Dsonar.projectName=platformreports-qa1.moglilabs.com-pipeline'
            
        } // SonarQube taskId is automatically attached to the pipeline context
    }

& for second,

stage('SonarQube analysis') {
        withSonarQubeEnv('Sonarqube') {
            sh 'sudo cp -r /data/automation/online/platformdata-qa1.moglilabs.com/config ${WORKSPACE}/dataload/src/main/resources/config/'
            sh 'cd ${WORKSPACE}/ && mvn clean package sonar:sonar -Dmaven.test.skip=true -Dsonar.projectName=platformdata-qa1.moglilabs.com-pipeline'
            
        } // SonarQube taskId is automatically attached to the pipeline context
    }

So the issue is both are working fine but when I’m building one project the current one overwrite previous one.
So can someone help what I’m missing.

Hi,

I guess you mean you have one build script for multiple projects?

I’m not seeing a difference in the code for the two different stages. Both even use the same project name. Although in terms of overwriting, that shouldn’t be a problem, it’s the sonar.projectKey value that’s critical.

I think you need to add -Dsonar.scanner.dumpToFile=[path to file], making sure to use a different path for each project. Then you can see what project key is being passed for each analysis.

 
Ann

Thanks