Hi I am automating code coverage on SonarCloud using Travis CI for a Maven
application.
Now, running the sonar:sonar
command locally submits the report on SoundCloud and I can see it as shown below with Branch master
Now I have also configured .travis.yml
file to auto push the report to SoundCloud on each build as below
But when build is triggered by Travis CI it fails with following error
[INFO] Load project branches
[INFO] Load project branches (done) | time=114ms
[INFO] Load project pull requests
[INFO] Load project pull requests (done) | time=116ms
[INFO] Load branch configuration
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 27.884 s
[INFO] Finished at: 2019-05-19T16:47:23Z
[INFO] Final Memory: 93M/496M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.6.0.1398:sonar (default-cli) on project safenest-java-server:
Project was never analyzed. A regular analysis is required before a branch analysis`
I am new to SonarCloud and couldn't find much documentation to get help with this. Can somebody explain what exactly A regular analysis is required
mean? And how to fix this?
Thanks in advance.
What happens during analysis? During analysis, data is requested from the server, the files provided to the analysis are analyzed, and the resulting data is sent back to the server at the end in the form of a report, which is then analyzed asynchronously server-side.
A regular analysis is required before a branch analysis" - Stack Overflow Travis CI SonarCloud error "Project was never analyzed. A regular analysis is required before a branch analysis"
Error using Travis CI with Sonarcloud: Not authorized. Please check the properties sonar.login and sonar.password I'm following Get started instructions on sonarcloud.io to execute the SonarQube Scanner for Maven from my computer:
You are trying to directly analyze a branch whereas your project has not been created yet. This is why you get the following message: Project was never analyzed. A regular analysis is required before a branch analysis This should fix your issue. Thanks for contributing an answer to Stack Overflow! Please be sure to answer the question.
You have to build main repository branch (usually master) with this configuration on Travis. After that you should be able to analyze all other branches. I hit the same problem when I was trying to analyze a feature branch which integrates my project with SonarCloud for the first time.
You should check following parameters:
Project key
generated during maven build and generated on SonarCloud (or make sure that you set sonar.projectKey property that was generated on SonarCloud).The error message means:
Please analyze main branch, before you will analyze other branches
You have to build main repository branch (usually master
) with this configuration on Travis. After that you should be able to analyze all other branches. I hit the same problem when I was trying to analyze a feature branch which integrates my project with SonarCloud for the first time. I just merged my feature to master
, pushed, and my project has been analyzed successfully. My configuration is similar to yours:
language: java
jdk: openjdk8
env: MVN_VERSION='3.6.0'
addons:
sonarcloud:
organization: $SONAR_ORGANIZATION
token:
secure: $SONAR_TOKEN
before_install:
- wget https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/$MVN_VERSION/apache-maven-$MVN_VERSION-bin.zip
- unzip -qq apache-maven-$MVN_VERSION-bin.zip
- export M2_HOME=$PWD/apache-maven-$MVN_VERSION
- export PATH=$M2_HOME/bin:$PATH
script:
- mvn -B -e verify site
- if [ -n "$SONAR_TOKEN" ]; then
mvn -B -e sonar:sonar -Dsonar.sources=pom.xml,src/main;
fi
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With