I try to set up pull request analysis on sonar. I got the error "Pull request with branch does not exist on server: develop". According to SonarQube Branch does not exist on server a new branch could be created by using the sonar.branch.name
property.
So I ran
mvn sonar:sonar -Dsonar.organization=edemo -Dsonar.analysis.mode=issues -Dsonar.branch.name=develop
my ~/.m2/settings.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>
<settings>
<pluginGroups>
<pluginGroup>org.sonarsource.scanner.maven</pluginGroup>
</pluginGroups>
<profiles>
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<!-- Optional URL to server. Default value is http://localhost:9000 -->
<sonar.host.url>https://sonarqube.com</sonar.host.url>
<sonar.login>[A sonar login token]</sonar.login>
</properties>
</profile>
</profiles>
</settings>
The relevant parts of pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
[...]
<properties>
[...]
<sonar.github.repository>edemo/PDEngine</sonar.github.repository>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.7.2</version>
<configuration>
<b>
<argLine>
-javaagent:${sonar.jacoco.jar}=destfile=${sonar.jacoco.reportPath}
</argLine>
</b>
<test>**/*.java</test>
</configuration>
</plugin>
[...]
</plugins>
</build>
[...]
</project>
But I do not see the develop branch under Administration/Branches & Pull Requests in my sonar project. Actually I do not see a new analysis report under activity.
Figured out: the problem was that I used issues as analysis mode. The right mode is publish. The command line correctly:
mvn sonar:sonar -Dsonar.organization=edemo -Dsonar.analysis.mode=publish -Dsonar.branch.name=develop
found the solution by reading this: Can't publish results to Sonarqube server