gabrie-allaigre / sonar-gitlab-plugin

Add to each commit GitLab in a global commentary on the new anomalies added by this commit and add comment lines of modified files
GNU Lesser General Public License v3.0
713 stars 208 forks source link

Issue on 'sonar.gitlab.prefix_directory' option #44

Open tnucera opened 7 years ago

tnucera commented 7 years ago

Hello,

I don't understand how the option 'sonar.gitlab.prefix_directory' works.

I run sonar-scanner with: sonar-scanner ... -Dsonar.gitlab.prefix_directory=service.hello/ ...

but the links which are generated in GitLab doesn't contain this prefix: https://mygitlab.com/myspace/myproject/blob/367e0aada65b46d813d5cf750daff2e398ff94c1/src/HelloBundle/HelloBundle.php#L6

I try to have: https://mygitlab.com/myspace/myproject/blob/367e0aada65b46d813d5cf750daff2e398ff94c1/service.hello/src/HelloBundle/HelloBundle.php#L6

Command:

docker run --rm -v $(pwd):$(pwd) -w $(pwd) myregistry.com:5000/docker/sonar-scanner \
            -Dsonar.analysis.mode=preview \
            -Dsonar.projectKey=myspace:myproject_test:service.hello_php-unit \
            -Dsonar.projectName=myspace:myproject_test:service.hello_php-unit \
            -Dsonar.projectVersion=${TAG} \
            -Dsonar.gitlab.project_id=${CI_PROJECT_PATH} \
            -Dsonar.gitlab.commit_sha=${CI_COMMIT_SHA} \
            -Dsonar.gitlab.ref_name=${CI_COMMIT_REF_NAME} \
            -Dsonar.gitlab.prefix_directory=service.hello/ \
            -Dsonar.sources=src -Dsonar.php.tests.reportPath=build/reports/junit.xml -Dsonar.php.coverage.reportPaths=build/reports/clover.xml

Output:

INFO: Scanner configuration file: /sonar-scanner/sonar-scanner-3.0.3.778/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarQube Scanner 3.0.3.778
INFO: Java 1.8.0_131 Oracle Corporation (64-bit)
INFO: Linux 4.4.0-77-generic amd64
INFO: User cache: /home/user/.sonar/cache
INFO: Load global settings
INFO: Load global settings (done) | time=519ms
INFO: User cache: /home/user/.sonar/cache
INFO: Exclude plugins: devcockpit, ldap, authgithub, authbitbucket, pdfreport, authaad, googleanalytics, governance
INFO: Load plugins index
INFO: Load plugins index (done) | time=137ms
INFO: Download sonar-crowd-plugin-2.0.jar
INFO: Download sonar-scm-git-plugin-1.2.jar
INFO: Download sonar-php-plugin-2.10.0.2087.jar
INFO: Download sonar-gitlab-plugin-2.0.1.jar
INFO: Download cks-slack-notifier-2.0.jar
INFO: SonarQube server 6.4.0
INFO: Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent)
INFO: Process project properties
INFO: Load project repositories
INFO: Load project repositories (done) | time=51ms
INFO: Execute project builders
INFO: Execute project builders (done) | time=1130ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=31ms
INFO: Load active rules
INFO: Load active rules (done) | time=85ms
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=102ms
INFO: Issues mode
INFO: Scanning only changed files
INFO: Project key: myspace:myproject_test:service.hello_php-unit
INFO: -------------  Scan myspace:myproject_test:service.hello_php-unit
INFO: Load server rules
INFO: Load server rules (done) | time=40ms
INFO: Base dir: /home/user/builds/b7573054/0/myspace/myproject/service.hello
INFO: Working dir: /home/user/builds/b7573054/0/myspace/myproject/service.hello/.scannerwork
INFO: Source paths: src
INFO: Source encoding: UTF-8, default locale: en_US
INFO: Index files
INFO: 12 files indexed
INFO: Quality profile for php: PSR-2
INFO: Sensor PHP sensor [php]
INFO: 1 source files to be analyzed
INFO: 1/1 source files have been analyzed
INFO: Analyzing PHPUnit test report: build/reports/junit.xml
INFO: Analyzing PHPUnit coverage report: build/reports/clover.xml
INFO: Sensor PHP sensor [php] (done) | time=997ms
INFO: Sensor Analyzer for "php.ini" files [php]
INFO: Sensor Analyzer for "php.ini" files [php] (done) | time=2ms
INFO: Load server issues
INFO: Load server issues (done) | time=31ms
INFO: Performing issue tracking
INFO: 21/21 components tracked
INFO: ANALYSIS SUCCESSFUL
INFO: Executing post-job GitLab Commit Issue Publisher
INFO: Report status=success, desc=SonarQube reported 2 issues, with 1 major and 1 minor
INFO: Task total time: 4.384 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 13.098s
INFO: Final Memory: 47M/383M
INFO: ------------------------------------------------------------------------

Thanks for the plugin and ur support.

gabrie-allaigre commented 7 years ago

Hi, Use 2.1.0-beta1 version ?

tnucera commented 7 years ago

Ah yes... thanks! When u will release this version? Anyway I'm ready. Good job.