Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin is executed yet doesn't add anything to commits in GitLab #3

Closed
DvdGiessen opened this issue Jul 1, 2016 · 34 comments
Closed

Comments

@DvdGiessen
Copy link

I seem to have some trouble getting this plugin set up correctly. I've added to plugin to SonarQube (currently 5.6, but I also tried with earlier versions), and set up all configuration for my project:

  • Created a user in GitLab, which has developer access to the relevant projects.
  • sonar.gitlab.url, sonar.gitlab.user_token and sonar.gitlab.max_global_issues set in SonarQube's global settings.
  • sonar.gitlab.project_id is also set in SonarQube's project settings.

I'm running using the Sonar Scanner (2.6.1) in a GitLab CI build, as follows:

sonar-scanner -Dsonar.host.url=$SONAR_HOSTNAME -Dsonar.projectKey=$SONAR_PROJECT_KEY -Dsonar.projectName=$SONAR_PROJECT_NAME -Dsonar.projectVersion=$SONAR_PROJECT_VERSION  -Dsonar.sources=./ -Dsonar.exclusions=vendor/** -Dsonar.login=$SONAR_USERNAME -Dsonar.password=$SONAR_PASSWORD -Dsonar.php.tests.reportPath=./phpunit-report.tests.xml -Dsonar.php.coverage.reportPath=./phpunit-report.coverage.xml -Dsonar.branch=$CI_BUILD_REF_NAME -Dsonar.gitlab.project_id=$CI_PROJECT_ID -Dsonar.gitlab.commit_sha=$CI_BUILD_REF -Dsonar.gitlab.ref_name=$CI_BUILD_REF_NAME

The scanner runs without errors, the scan results appear in SonarQube and judging by the output the GitLab plugin is loaded and executed. (See http://pastebin.com/dySw8B2N for the output.)

However, the plugin doesn't seem to work: No comments are added in GitLab to any new commits.

I'm not sure if I'm missing something in my configuration, but as far as I can gather from the README I've set up everything correctly, and the output doesn't show any errors or other messages to point me in the direction of any solution.

@gabrie-allaigre
Copy link
Owner

Hi,
have you a new issue ?
Add in mvn command -Dsonar.issuesReport.console.enable=true

2016-07-01 15:22 GMT+02:00 Daniël van de Giessen notifications@github.com:

I seem to have some trouble getting this plugin set up correctly. I've
added to plugin to SonarQube (currently 5.6, but I also tried with earlier
versions), and set up all configuration for my project:

  • Created a user in GitLab, which has developer access to the relevant
    projects.
  • sonar.gitlab.url, sonar.gitlab.user_token and
    sonar.gitlab.max_global_issues set in SonarQube's global settings.
  • sonar.gitlab.project_id is also set in SonarQube's project settings.

I'm running using the Sonar Scanner (2.6.1) in a GitLab CI build, as
follows:

sonar-scanner -Dsonar.host.url=$SONAR_HOSTNAME -Dsonar.projectKey=$SONAR_PROJECT_KEY -Dsonar.projectName=$SONAR_PROJECT_NAME -Dsonar.projectVersion=$SONAR_PROJECT_VERSION -Dsonar.sources=./ -Dsonar.exclusions=vendor/** -Dsonar.login=$SONAR_USERNAME -Dsonar.password=$SONAR_PASSWORD -Dsonar.php.tests.reportPath=./phpunit-report.tests.xml -Dsonar.php.coverage.reportPath=./phpunit-report.coverage.xml -Dsonar.branch=$CI_BUILD_REF_NAME -Dsonar.gitlab.project_id=$CI_PROJECT_ID -Dsonar.gitlab.commit_sha=$CI_BUILD_REF -Dsonar.gitlab.ref_name=$CI_BUILD_REF_NAME

The scanner runs without errors, the scan results appear in SonarQube and
judging by the output the GitLab plugin is loaded and executed. (See
http://pastebin.com/dySw8B2N for the output.)

However, the plugin doesn't seem to work: No comments are added in GitLab
to any new commits.

I'm not sure if I'm missing something in my configuration, but as far as I
can gather from the README I've set up everything correctly, and the output
doesn't show any errors or other messages to point me in the direction of
any solution.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#3, or mute
the thread
https://github.com/notifications/unsubscribe/AOTLeYS0-CwMjkyvaXo9E8Gt1QNWm44Zks5qRRSUgaJpZM4JDI55
.

Gabriel ALLAIGRE

Directeur technique

[image: Le blog de TalanLabs]

8 rue Euler

75008 PARIS

Tel : 01 53 34 05 72

Por : 06 22 33 78 56

gabriel.allaigre@talanlabs.com

www.talanlabs.com

PAdoptez l'éco-attitude. N'imprimez ce mail que si cela est vraiment

nécessaire

Ce message contient des informations confidentielles protégées par le
secret professionnel. Au cas où il ne vous serait pas destiné, nous vous
remercions de bien vouloir nous en aviser immédiatement et de le supprimer.

The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited. If you received
this in error, please contact the sender and delete the material from any
computer.

@DvdGiessen
Copy link
Author

Setting sonar.issuesReport.console.enable doesn't generate a list of issues in the console; after searching for a bit it seems that the Issues Report plugin has been deprecated since SQ 5.1?

There were (multiple) new issues were introduced in that commit, and those new issues did show up in the SonarQube web interface. (I've tested with multiple commits, all with different kind of issues introduced. SonarQube picks them up, they just don't get commented on in GitLab.)

@gabrie-allaigre
Copy link
Owner

GitLab plugin must a sonar preview mode only

2016-07-01 20:10 GMT+02:00 Daniël van de Giessen notifications@github.com:

Setting sonar.issuesReport.console.enable doesn't generate a list of
issues in the console; after searching for a bit it seems that the Issues
Report plugin has been deprecated since SQ 5.1?

There were (multiple) new issues were introduced in that commit, and those
new issues did show up in the SonarQube web interface. (I've tested with
multiple commits, all with different kind of issues introduced. SonarQube
picks them up, they just don't get commented on in GitLab.)


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#3 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AOTLeeM_FHLiHUT4mrgRfTWCV3eOB7SRks5qRVgHgaJpZM4JDI55
.

Gabriel ALLAIGRE

Directeur technique

[image: Le blog de TalanLabs]

8 rue Euler

75008 PARIS

Tel : 01 53 34 05 72

Por : 06 22 33 78 56

gabriel.allaigre@talanlabs.com

www.talanlabs.com

PAdoptez l'éco-attitude. N'imprimez ce mail que si cela est vraiment

nécessaire

Ce message contient des informations confidentielles protégées par le
secret professionnel. Au cas où il ne vous serait pas destiné, nous vous
remercions de bien vouloir nous en aviser immédiatement et de le supprimer.

The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited. If you received
this in error, please contact the sender and delete the material from any
computer.

@DvdGiessen
Copy link
Author

Ah, that was the issue! Running the scanner in preview mode (-Dsonar.analysis.mode=preview) resolved it.

Is this a inherent limitation of how Sonar Scanner operates? Right now I have to run the analysis twice, once for the GitLab-plugin to work and then directly again to also actually publish the results to SonarQube.

@rbosneag
Copy link

rbosneag commented Nov 25, 2016

In my case sonar.analysis.mode=preview didn't work either, tried also with dryRun true/false.
I wonder why the GitLab plugin is tied to the preview option, why not allow to post in GitLab for full analysis as well?

Regarding running the analysis twice, it looks like it's by design: http://www.sonarqube.org/analysis-vs-preview-vs-incremental-preview-in-sonarqube/ and it makes sense, but it would still be nice to have the comments in GitLab for full analysis.

@gabrie-allaigre any news on this matter?
@DvdGiessen how did you manage to setup your flows?

@la-urre
Copy link

la-urre commented Dec 16, 2016

I don't know if this will help but I was not seeing any comments neither. My solution was to:

  • use the preview mode to launch the analysis, else it will not work
  • as I had not activated the preview mode, the new issues were registered in my Sonar server. So when I found that I needed to use the preview mode, the issues were not new, and no comment showed up in GitLab. So make sure that the issues are really new, and that Sonar hasn't seem them already.

To help troubleshoot the second problem, I had to clone this plugin, add debug traces in the console in various files and upload the modified version of the plugin to the Sonar server. This surely helps !

@gtrias
Copy link

gtrias commented Jan 4, 2017

Nothing of the above has helped me in running this plugin successfully. I tried everything with no sucess.

  • The sonar-scanner runs well and reports no error.
  • The preview mode is enabled.
  • The new issues are reported to sonarqube well.
  • The sonarqube can post messages to gitlab since if I enable GitLab Comment On No New Issue option it sais there's no issues..

But no issue message in gitlab of any mistake in the code :(

@la-urre
Copy link

la-urre commented Jan 4, 2017

Something bugs me: if the preview mode is really enabled, new issues should NOT be reported to sonarqube.

@gtrias
Copy link

gtrias commented Jan 4, 2017

Well I'm executing sonar-scanner from go.cd ant the reported running command is:

19:23:22.271 [go] Start to execute task: <exec command="sh" >
<arg>-c</arg>
<arg>sonar-scanner</arg>
<arg>-Dsonar.issuesReport.console.enable=true</arg>
<arg>-Dsonar.gitlab.ref_name=master</arg>
<arg>-Dsonar.analysis.mode=preview</arg>
<arg>-Dsonar.gitlab.commit_sha=$GO_TO_REVISION</arg>

Edit:
Ok I see. It seems the parameter -Dsonar.analysis.mode=preview does nothing. I have had to put this configuration in sonar-project.properties to run in preview mode.
Now I'm having another different error:

19:30:30.479 java.lang.IllegalStateException: No language plugins are installed.
19:30:30.479 	at org.sonar.scanner.repository.language.DefaultLanguagesRepository.start(DefaultLanguagesRepository.java:46)
19:30:30.479 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
19:30:30.479 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
19:30:30.479 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
19:30:30.479 	at java.lang.reflect.Method.invoke(Method.java:498)
19:30:30.479 	at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.invokeMethod(ReflectionLifecycleStrategy.java:110)
19:30:30.479 	at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.start(ReflectionLifecycleStrategy.java:89)
19:30:30.479 	at org.sonar.core.platform.ComponentContainer$1.start(ComponentContainer.java:320)
19:30:30.479 	at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.start(AbstractInjectionFactory.java:84)
19:30:30.479 	at org.picocontainer.behaviors.AbstractBehavior.start(AbstractBehavior.java:169)
19:30:30.479 	at org.picocontainer.behaviors.Stored$RealComponentLifecycle.start(Stored.java:132)
19:30:30.479 	at org.picocontainer.behaviors.Stored.start(Stored.java:110)
19:30:30.479 	at org.picocontainer.DefaultPicoContainer.potentiallyStartAdapter(DefaultPicoContainer.java:1016)
19:30:30.479 	at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1009)
19:30:30.480 	at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:767)
19:30:30.480 	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:141)
19:30:30.480 	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
19:30:30.480 	at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:47)
19:30:30.480 	at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:86)
19:30:30.482 	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
19:30:30.482 	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
19:30:30.482 	at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:115)
19:30:30.482 	at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:116)
19:30:30.483 	at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:62)
19:30:30.483 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
19:30:30.483 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
19:30:30.483 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
19:30:30.483 	at java.lang.reflect.Method.invoke(Method.java:498)
19:30:30.483 	at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
19:30:30.483 	at com.sun.proxy.$Proxy0.execute(Unknown Source)
19:30:30.483 	at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:233)
19:30:30.483 	at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151)
19:30:30.483 	at org.sonarsource.scanner.cli.Main.runAnalysis(Main.java:110)
19:30:30.483 	at org.sonarsource.scanner.cli.Main.execute(Main.java:74)
19:30:30.483 	at org.sonarsource.scanner.cli.Main.main(Main.java:61)
19:30:30.483 ERROR: 
19:30:30.483 ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
19:30:30.509 [go] Current job status: failed.

I'll keep trying things...

@la-urre
Copy link

la-urre commented Jan 4, 2017

The error seems quite clear, do you have any language plugin installed on your SonarQube server ?

@gtrias
Copy link

gtrias commented Jan 4, 2017

I thought the same an it was the first thing to check with no success. I've tried to:

  • reinstall javascript plugin in sonarqube server.
  • try to change language in sonar-project.properties from js to javascript
  • set quality profile to the project in sonarqube server.

Nothing has changed. But it seems weird to me that other scan types were able to find the proper plugins.

I've found the same error published in google goups but still not fixed:

https://groups.google.com/forum/#!topic/sonarqube/G77UKtXQUAo

@ghost
Copy link

ghost commented Jan 17, 2017

Hi @gtrias ,

Have given some guidance on the Google Group thread where the same error was reported.

Long story short: double-check what's configured in your SonarQube Admin settings (General section), for the properties Plugins accepted for Preview mode and Plugins excluded for Preview mode. These properties restrict the set of plugins seen by the scanner when executed in preview mode, so it can likely explain why your preview analysis fails with No language plugins are installed (e.g. if include/exclude properties hide all language plugins). Best is to leave the include property blank, and review what you decide to exclude.

Keep us posted.

@gtrias
Copy link

gtrias commented Jan 17, 2017

@n-b-sonar Thank you so much!! Was the "Plugins accepted for Preview mode", I didn't known there was an option to avoid the preview mode to fetch all the plugins.
After removing the Plugins accepted it just works!!
Thanks again

@amilien
Copy link

amilien commented Feb 27, 2017

I want to understand better how this plugin works with Gitlab CI. My goal is to run this plugin on Gitlab MRs so it could make necessary comments there.
What I did so far:

  1. Installed and ran locally Sonarqube with sonar-gitlab-plugin and java plugin for my android project.
  2. Set up SonarQube's global and project settings.

I was able to launch full project sonar analysis by ./gradlew sonarqube.
Now my question is how to launch the sonar analysis only for changes in MR? Is it just enough to add following in .gitlab-ci.yml?

sh gradlew sonarqube -Psonar.analysis.mode=preview -Psonar.issuesReport.console.enable=true \ -Psonar.gitlab.commit_sha=$CI_BUILD_REF -Psonar.gitlab.ref_name=$CI_BUILD_REF_NAME \ -Psonar.gitlab.project_id=$CI_PROJECT_ID

These variables - $CI_BUILD_REF, $CI_BUILD_REF_NAME, $CI_PROJECT_ID - will they be automatically resolved?

@la-urre
Copy link

la-urre commented Feb 28, 2017

These variables are predefined by GitLab and accessible from the .gitlab-ci.yml file. See here : https://docs.gitlab.com/ce/ci/variables/.

The only thing different in my script is the -Psonar.gitlab.project_id=$CI_PROJECT_ID.
I personally use -Psonar.gitlab.project_id=projectGroup/projectName. Which seems to be equivalent with -Psonar.gitlab.project_id=$CI_PROJECT_PATH.

@johnou
Copy link
Contributor

johnou commented Mar 2, 2017

@amilien here is my .gitlab-ci.yml for sonarqube

sonarqube_preview:
  script:
    - mvn --batch-mode verify sonar:sonar -DskipITs -DskipTests -Dgpg.sign=false -Dsonar.host.url=https://xxx -Dsonar.gitlab.project_id=$CI_PROJECT_PATH -Dsonar.analysis.mode=preview -Dsonar.issuesReport.console.enable=true -Dsonar.gitlab.commit_sha=$CI_BUILD_REF -Dsonar.gitlab.ref_name=$CI_BUILD_REF_NAME
  stage: test
  except:
    - develop
    - master
    - /^hotfix_.*$/
    - /.*-hotfix$/
  tags:
    - java

sonarqube:
  script:
    - mvn --batch-mode verify sonar:sonar -DskipITs -DskipTests -Dgpg.sign=false -Dsonar.host.url=https://xxx
  stage: test
  only:
    - master
  tags:
    - java

@johnou
Copy link
Contributor

johnou commented Mar 18, 2017

@DvdGiessen please try with 2.0.0-beta2 and report back.

@johnou
Copy link
Contributor

johnou commented Mar 18, 2017

wow, just scrolled up and see your issue was actually resolved here #3 (comment)

@gabrie-allaigre should be good to close this issue 👍

@dinhkk
Copy link

dinhkk commented Mar 22, 2017

I used sonar-gitlab-plugin for php. The test project is sample project of sonarqube scanner.
Many thanks to @johnou
The following configuration worked for me.
File sonar-project.properties:

sonar.projectKey=org.sonarqube:$CI_PROJECT_NAME
sonar.projectName=PHP :: ${CI_PROJECT_NAME}
sonar.projectVersion=1.0

sonar.language=php
sonar.sources=./
sonar.sourceEncoding=UTF-8

File .gitlab-ci.yml

sonarqube_preview:
  script:
    - sonar-scanner -Dgpg.sign=false -Dsonar.host.url=http://domain:9101 -Dsonar.gitlab.project_id=$CI_PROJECT_PATH -Dsonar.analysis.mode=preview -Dsonar.issuesReport.console.enable=true -Dsonar.gitlab.commit_sha=$CI_BUILD_REF -Dsonar.gitlab.ref_name=$CI_BUILD_REF_NAME
  stage: test

sonarqube:
  script:
    - sonar-scanner -Dgpg.sign=false -Dsonar.host.url=http://domain.com:9101
  stage: test
  only:
    - master

Result on gitlab:
On gitlab
Result on sonarqube:
On sonarqube

@johnou
Copy link
Contributor

johnou commented Mar 23, 2017

@dinhkk I think you can drop -Dgpg.sign=false

@gabrie-allaigre
Copy link
Owner

Good,

@chenyurong
Copy link

chenyurong commented Apr 21, 2017

It have some trouble in configure sonar-gitlab-plugin. @gabrie-allaigre

I want SonarQube to report the analysis result to gitlab, and I had done the following step:

  • install sonar-gitlab-plugin in sonar
  • configure gitlab server infomation in Administrator-General Setting.
  • configure GitLab Project id in Project-Administrator Setting.
  • setting in the .m2/setting.xml with following :
<pluginGroups>
        <pluginGroup>org.sonarsource.scanner.maven</pluginGroup>
</pluginGroups> 
.......
<profile>
        <id>sonar</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <properties>
            <!-- Optional URL to server. Default value is http://localhost:9000 -->
            <sonar.host.url>http://localhost:9000</sonar.host.url>
        </properties>
    </profile>
......

then I go into my maven project root directory(where pom.xml stay in), and use the following command:

mvn --batch-mode verify sonar:sonar -Dsonar.analysis.mode=preview -Dsonar.gitlab.commit_sha=649d921e8a029c86158c42d9bc40e47afaf055ac -Dsonar.gitlab.ref_name=master -Dsonar.gitlab.project_id=sonarqube_code

but the result tells me something is wrong :

[INFO] Plugin [l10nzh] defines 'l10nen' as base plugin. This metadata can be removed from manifest of l10n plugins since version 5.2.
[INFO] SonarQube version: 5.6.6
[INFO] Default locale: "en_US", source code encoding: "UTF-8"
[INFO] Process project properties
[INFO] Load project repositories
[INFO] Load project repositories (done) | time=228ms
[INFO] Execute project builders
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.222 s
[INFO] Finished at: 2017-04-21T00:49:19-07:00
[INFO] Final Memory: 49M/118M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.3.0.603:sonar (default-cli) on project code: Unable to load component class org.sonar.batch.scan.ImmutableProjectReactor: Unable found project for sonarqube_code Verify Configuration sonar.gitlab.project_id or sonar.gitlab.user_token access project -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

but when I run with mvn --batch-mode verify sonar:sonar -Dsonar.analysis.mode=preview -Dsonar.gitlab.project_id=sonarqube_code, the project compile SUCCESS. but no inline comment in Gitlab.

@gabrie-allaigre
Copy link
Owner

Hi,
sonar.gitlab.project_id=sonarqube_code is wrong, Format is Project ID in GitLab or internal id or namespace + name or namespace + path or url http or ssh url or url or web.

For mvn --batch-mode verify sonar:sonar -Dsonar.analysis.mode=preview -Dsonar.gitlab.project_id=sonarqube_code, the project compile SUCESS because plugin is not enable, For enable plugin, sonar.gitlab.commit_sha is mandatory

@chenyurong
Copy link

Thanks for your reply, I had been trying to solve this problem for several days. @gabrie-allaigre

Follow your reply, I change the value of sonar.gitlab.project_id into one of three value:

that means I run the following three command seprately:

mvn --batch-mode verify sonar:sonar -Dsonar.analysis.mode=preview -Dsonar.gitlab.commit_sha=649d921e8a029c86158c42d9bc40e47afaf055ac -Dsonar.gitlab.ref_name=master -Dsonar.gitlab.project_id=code

mvn --batch-mode verify sonar:sonar -Dsonar.analysis.mode=preview -Dsonar.gitlab.commit_sha=649d921e8a029c86158c42d9bc40e47afaf055ac -Dsonar.gitlab.ref_name=master -Dsonar.gitlab.project_id=git@gitlab.chenyurong.com:chenyurong/code.git

mvn --batch-mode verify sonar:sonar -Dsonar.analysis.mode=preview -Dsonar.gitlab.commit_sha=649d921e8a029c86158c42d9bc40e47afaf055ac -Dsonar.gitlab.ref_name=master -Dsonar.gitlab.project_id=http://chenyurong@gitlab.chenyurong.com/chenyurong/code.git

but they all turns the same error :

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.580 s
[INFO] Finished at: 2017-04-21T02:52:51-07:00
[INFO] Final Memory: 49M/118M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.3.0.603:sonar (default-cli) on project code: Unable to load component class org.sonar.batch.scan.ImmutableProjectReactor: Unable found project for http://chenyurong@gitlab.chenyurong.com/chenyurong/code.git Verify Configuration sonar.gitlab.project_id or sonar.gitlab.user_token access project -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]

would you know what's wrong with the maven command. thanks.

@gabrie-allaigre
Copy link
Owner

try chenyurong/code
or http://gitlab.chenyurong.com/chenyurong/code.git

@gabrie-allaigre
Copy link
Owner

Have you set access token in SonarQube ?

@chenyurong
Copy link

what do you mean access token in SonarQube, in which menu ?

@gabrie-allaigre
Copy link
Owner

In SonarQube Administration -> General Settings -> GitLab -> GitLab User Token

@chenyurong
Copy link

Just now I add the -Dsonar.gitlab.user_token to previous maven command and it works.

mvn --batch-mode verify sonar:sonar -Dsonar.analysis.mode=preview -Dsonar.gitlab.commit_sha=649d921e8a029c86158c42d9bc40e47afaf055ac -Dsonar.gitlab.ref_name=master -Dsonar.gitlab.user_token=xgxpcGw-TzsRDmkFG-9S -Dsonar.gitlab.project_id=git@gitlab.chenyurong.com:chenyurong/code.git

the project compile SUCCESS. But when I browse the SonarQube Web Page, the code project seems doesn't update according to the LAST ANALYSIS column. Is it because I use the verify in maven command ?

by the way, I did set the GitLab User Token already in SonarQube Administration -> General Settings -> GitLab -> GitLab User Token.

@gabrie-allaigre
Copy link
Owner

Sonar preview mode not change page in SonarQube.
In cmd, see

[INFO] ANALYSIS SUCCESSFUL
[INFO] Executing post-job GitLab Commit Issue Publisher
[INFO] Report status=success, desc=SonarQube reported no issues

@chenyurong
Copy link

Thanks for your instruction, I really really appreciate that. Without your reply, maybe I can't solve this problem.

I can see the inline comment in gitlab now. Thanks again~~

@gabrie-allaigre
Copy link
Owner

Good

@JokerDevops
Copy link

hi

@JokerDevops
Copy link

Hi everyone, can this question be reopened? My problems:when I used mvn --batch-mode verify sonar:sonar \ -Dsonar.host.url=http://192.168.0.51:9000 \ -Dsonar.login=admin \ -Dsonar.password=admin \ -Dsonar.analysis.mode=preview \ -Dsonar.gitlab.project_id=$CI_PROJECT_ID \ -Dsonar.gitlab.commit_sha=$CI_COMMIT_SHA \ -Dsonar.gitlab.ref_name=$CI_COMMIT_REF_NAME He was successful. I saw sonarqube's detection information.But he reported an error when I used sonar-scanner.The project profile for sonar - scanner is as follows

sonar.projectKey=org.sonarqube:java-print-demo-scanner
sonar.projectName=Java :: print-demo :: SonarQube Scanner
sonar.projectVersion=1.0
sonar.sources=src
sonar.language=java
sonar.sourceEncoding=UTF-8
sonar.login=admin
sonar.password=admin
sonar.analysis.mode=preview
sonar.issuesReport.console.enable=true
sonar.gitlab.project_id=$CI_PROJECT_PATH
sonar.gitlab.commit_sha=$GIT_COMMIT
sonar.gitlab.ref_name=$GIT_BRANCH

The error message after executing sonar-scanner is as follows:

Caused by: Failed to execute project builder: com.talanlabs.sonar.plugins.gitlab.CommitProjectBuilder
Caused by: java.lang.IllegalStateException: Unable found project for $CI_PROJECT_PATH Verify Configuration sonar.gitlab.project_id or sonar.gitlab.user_token access project

I hope to get your help. Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants