Custom report for Java imported on SonarQube but not on Sonar Cloud

I’m trying to upload a custom report created by custom plugin for maven i created.

Environment:

Multi-module maven project
Java 17
Build on Azure DevOps
Sonar plugin defined in parent pom as part of profile sonar as follows:

<profile>
	<build>
		<pluginManagement>
			<plugins>
				<plugin>
					<!-- To run custom rules -->
					<groupId>**********</groupId>
					<artifactId>sonar-custom-rules-plugin</artifactId>
					<version>${sonar-custom-rules-plugin.version}</version>
				</plugin>
				<plugin>
					<groupId>org.sonarsource.scanner.maven</groupId>
					<artifactId>sonar-maven-plugin</artifactId>
					<version>${sonar-maven-plugin.version}</version>
				</plugin>
			</plugins>
		</pluginManagement>
		<plugins>
			<plugin>
				<executions>
					<execution>
						<phase>test</phase>
						<goals>
							<goal>scan-execute</goal>
						</goals>
					</execution>
				</executions>
				<configuration>
					<testMode>true</testMode>
				</configuration>
				<groupId>*************</groupId>
				<artifactId>sonar-custom-rules-plugin</artifactId>
			</plugin>
			<plugin>
				<executions>
					<execution>
						<phase>test</phase>
						<goals>
							<goal>sonar</goal>
						</goals>
					</execution>
				</executions>
				<artifactId>sonar-maven-plugin</artifactId>
				<groupId>org.sonarsource.scanner.maven</groupId>
			</plugin>
		</plugins>
	</build>
	<id>sonar</id>
	<properties>
		<sonar-maven-plugin.version>3.9.1.2184</sonar-maven-plugin.version>
		<sonar.externalIssuesReportPaths>${project.build.directory}/digital-tech-sonar-custom-rules-plugin-report.json
        </sonar.externalIssuesReportPaths>
	</properties>
</profile>

For context, sonar-custom-rules-plugin outputs file digital-tech-sonar-custom-rules-plugin-report.json for every module in the project.

When running following config locally against a local instance of SonarQube(running in Docker), everything went fine, and issues were imported(see screenshot)

Now when running the same thing in Azure, against our SonarCloud instance, the issues don’t show up under the branch that is being scanned. I even enabled the debug logs and for every module that is being processed by the sonar-maven-plugin, i can see following logs indicating that the report should be formatted correctly and the issues were recognized and imported to respective files:

2023-08-22T18:26:20.0413815Z [DEBUG] 18:22:48.101 Importing issues from '/__w/17/s/digital-tech-commons-audit/target/digital-tech-sonar-custom-rules-plugin-report.json' 
2023-08-22T18:26:20.0414331Z [INFO] 18:22:48.102 Imported 8 issues in 8 files

2023-08-22T18:26:12.0066921Z [DEBUG] 18:22:47.219 Importing issues from '/__w/17/s/digital-tech-commons-adl/target/digital-tech-sonar-custom-rules-plugin-report.json' 
2023-08-22T18:26:12.0067239Z [INFO] 18:22:47.220 Imported 7 issues in 7 files 

Any idea what might be happening or how to debug this further ?

Hey there.

If you’re analyzing a short-lived branch (a concept that no longer exists on SonarQube but does in SonarCloud) – you only see issues on changed lines (like when analyzing a pull request).

Do you see the issues on your main branch or any other long-lived branch?

See the docs on branch analysis

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.