sonar-gitlab-plugin icon indicating copy to clipboard operation
sonar-gitlab-plugin copied to clipboard

Project was never analyzed. A regular analysis is required before a branch analysis

Open manasatest opened this issue 5 years ago • 9 comments

$ ./gradlew sonarqube -Dsonar.host.url=$SONAR_URL -Dsonar.login=$SONAR_TOKEN -Dsonar.gitlab.project_id=$CI_PROJECT_ID -Dsonar.gitlab.commit_sha=$CI_COMMIT_SHA -Dsonar.gitlab.ref_name=$CI_COMMIT_REF_NAME -Dsonar.branch.name=$CI_COMMIT_REF_NAME

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':sonarqube'.

Project was never analyzed. A regular analysis is required before a branch analysis

Running analysis using -Dsonar.branch.name=$CI_COMMIT_REF_NAME on gitlab always fails for branch/master. How to fix this issue for all the branches? Does sonar need always master analysis to be run first to create the project on sonar dashboard?

I'm using Sonarqube 7.5 EE.

manasatest avatar Mar 24 '19 19:03 manasatest

Hi, Not use plugin with master, use only for others branches (feature branch) Branch plugin compare with master, if not master, error. Start analyze without use plugin

gabrie-allaigre avatar Mar 28 '19 20:03 gabrie-allaigre

Hi, You meant not to use the branch plugin for master?

manasatest avatar Mar 29 '19 15:03 manasatest

For master, not use -Dsonar.gitlab.project_id=$CI_PROJECT_ID -Dsonar.gitlab.commit_sha=$CI_COMMIT_SHA -Dsonar.gitlab.ref_name=$CI_COMMIT_REF_NAME

gabrie-allaigre avatar Mar 29 '19 15:03 gabrie-allaigre

Is there a reason why we don't use it? This is how its working for me.

This step runs the sonar analysis to preview the comments on GitLab

sonarqube_preview: stage: analysis variables: SONAR_ANALYSIS_MODE: preview dependencies: - test image: ciricihq/gitlab-sonar-scanner script:

  • gitlab-sonar-scanner -Dsonar.host.url=$SONAR_URL -Dsonar.login=$SONAR_TOKEN -Dsonar.gitlab.project_id=$CI_PROJECT_ID -Dsonar.gitlab.commit_sha=$CI_COMMIT_SHA -Dsonar.gitlab.ref_name=$CI_COMMIT_REF_NAME -Dsonar.branch.name=$CI_COMMIT_REF_NAME

This step runs the sonar analysis for master only

sonarqube-reports-master: stage: analysis variables: SONAR_ANALYSIS_MODE: publish dependencies: - test only: - master image: ciricihq/gitlab-sonar-scanner script: - gitlab-sonar-scanner -Dsonar.host.url=$SONAR_URL -Dsonar.login=$SONAR_TOKEN -Dsonar.gitlab.project_id=$CI_PROJECT_ID -Dsonar.gitlab.commit_sha=$CI_COMMIT_SHA -Dsonar.gitlab.ref_name=$CI_COMMIT_REF_NAME

This step runs the sonar analysis for branches only

sonarqube-reports-branch: stage: analysis variables: SONAR_ANALYSIS_MODE: publish dependencies: - test except: - master image: ciricihq/gitlab-sonar-scanner script: - gitlab-sonar-scanner -Dsonar.branch.name=$CI_COMMIT_REF_NAME

manasatest avatar Mar 29 '19 15:03 manasatest

Hi, I keep getting this error:

[91mERROR: Error during SonarQube Scanner execution [0m[91mERROR: Project was never analyzed. A regular analysis is required before a branch analysis [0m[91mERROR: [0m[91mThe SonarQube Scanner did not complete successfully [0m07:25:09.62 Creating a summary markdown file... [91m07:25:09.621 Post-processing failed. Exit code: 1 [0mThe command '/bin/sh -c dotnet /sonar-scanner/SonarScanner.MSBuild.dll end /d:sonar.login=

???

cristemm avatar Aug 08 '19 08:08 cristemm

I have same error in gitlab ci you do not have to specify the branch name in your script remove sonar.branch.name="$CI_COMMIT_REF_NAME" from your script

asakkour avatar Sep 26 '19 10:09 asakkour

I'm getting this same error. We're trying to use SonarCloud to analyse our project on Github.

My action is:

name: "Analyze code with SonarCloud"

on:
  push:
    branches:
      - develop
      - enable-sonarcloud-java

jobs:
  sonarCloudTrigger:
    name: SonarCloud Trigger
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@master
      - name: Setup build environment
        uses: actions/setup-java@v1
        with:
          java-version: 1.8
      - name: Build
        run: mvn sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Pci
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

(enable-sonarcloud-java is the testing branch I'm using)

The build runs and fails with the following error message:

2019-11-27T14:03:05.1655383Z Downloaded from central: https://repo.maven.apache.org/maven2/org/sonarsource/scanner/api/sonar-scanner-api/2.14.0.2002/sonar-scanner-api-2.14.0.2002.jar (625 kB at 6.8 MB/s)
2019-11-27T14:03:05.2652037Z [INFO] User cache: /home/runner/.sonar/cache
2019-11-27T14:03:07.2427672Z [INFO] SonarQube version: 8.0.0
2019-11-27T14:03:07.2898672Z [INFO] Default locale: "en", source code encoding: "UTF-8"
2019-11-27T14:03:07.5670037Z [INFO] Load global settings
2019-11-27T14:03:08.1794379Z [INFO] Load global settings (done) | time=613ms
2019-11-27T14:03:08.1860889Z [INFO] Server id: 74E9293D-AWHW8ct9-T_TB3XqouNu
2019-11-27T14:03:08.1911578Z [INFO] User cache: /home/runner/.sonar/cache
2019-11-27T14:03:08.1936476Z [INFO] Load/download plugins
2019-11-27T14:03:08.1938162Z [INFO] Load plugins index
2019-11-27T14:03:08.3655147Z [INFO] Load plugins index (done) | time=170ms
2019-11-27T14:03:30.3990797Z [INFO] Load/download plugins (done) | time=22205ms
2019-11-27T14:03:30.6718708Z [INFO] Loaded core extensions: developer-scanner
2019-11-27T14:03:31.5526487Z [INFO] Process project properties
2019-11-27T14:03:31.5695993Z [INFO] Execute project builders
2019-11-27T14:03:31.5741613Z [INFO] Execute project builders (done) | time=4ms
2019-11-27T14:03:31.5779050Z [INFO] Project key: org.comixed:comixed
2019-11-27T14:03:31.5779358Z [INFO] Base dir: /home/runner/work/comixed/comixed
2019-11-27T14:03:31.5779754Z [INFO] Working dir: /home/runner/work/comixed/comixed/target/sonar
2019-11-27T14:03:31.5860535Z [INFO] Load project settings for component key: 'org.comixed:comixed'
2019-11-27T14:03:31.7549088Z [INFO] Found an active CI vendor: 'Github Actions'
2019-11-27T14:03:31.7577306Z [INFO] Load project branches
2019-11-27T14:03:31.8514915Z [INFO] Load project branches (done) | time=96ms
2019-11-27T14:03:31.8545741Z [INFO] Load project pull requests
2019-11-27T14:03:31.9509226Z [INFO] Load project pull requests (done) | time=96ms
2019-11-27T14:03:31.9530111Z [INFO] Load branch configuration
2019-11-27T14:03:31.9545240Z [INFO] Github event: push
2019-11-27T14:03:32.1408893Z [INFO] Auto-configuring branch enable-sonarcloud-java
2019-11-27T14:03:32.1486127Z [INFO] ------------------------------------------------------------------------
2019-11-27T14:03:32.1487462Z [INFO] Reactor Summary:
2019-11-27T14:03:32.1488406Z [INFO] 
2019-11-27T14:03:32.1492233Z [INFO] comixed-parent 0.5.0-PRERELEASE .................... FAILURE [ 33.398 s]
2019-11-27T14:03:32.1494964Z [INFO] comixed-library 0.5.0-PRERELEASE ................... SKIPPED
2019-11-27T14:03:32.1497212Z [INFO] comixed-tasks 0.5.0-PRERELEASE ..................... SKIPPED
2019-11-27T14:03:32.1499174Z [INFO] comixed-services 0.5.0-PRERELEASE .................. SKIPPED
2019-11-27T14:03:32.1501226Z [INFO] comixed-rest-api 0.5.0-PRERELEASE .................. SKIPPED
2019-11-27T14:03:32.1503873Z [INFO] comixed-frontend 0.5.0-PRERELEASE .................. SKIPPED
2019-11-27T14:03:32.1506044Z [INFO] comixed-app 0.5.0-PRERELEASE ....................... SKIPPED
2019-11-27T14:03:32.1508623Z [INFO] comixed-importer 0.3.9-SNAPSHOT .................... SKIPPED
2019-11-27T14:03:32.1510623Z [INFO] ------------------------------------------------------------------------
2019-11-27T14:03:32.1511756Z [INFO] BUILD FAILURE
2019-11-27T14:03:32.1515311Z [INFO] ------------------------------------------------------------------------
2019-11-27T14:03:32.1517045Z [INFO] Total time:  40.480 s
2019-11-27T14:03:32.1520575Z [INFO] Finished at: 2019-11-27T14:03:32Z
2019-11-27T14:03:32.1524349Z [INFO] ------------------------------------------------------------------------
2019-11-27T14:03:32.1536110Z [ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar (default-cli) on project comixed: Project was never analyzed. A regular analysis is required before a branch analysis. -> [Help 1]

mcpierce avatar Nov 27 '19 14:11 mcpierce

I have the same erro from an ADO run using sonaqube ERROR: Error during SonarScanner execution

ERROR: Project was never analyzed. A regular analysis is required before a branch analysis

this is the firstime this repo is being scanned in sonaqube

rediphone avatar Oct 23 '20 10:10 rediphone

@rediphone - did you get anywhere with this?

jKlaus-KI avatar Oct 26 '20 18:10 jKlaus-KI