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 207 forks source link

Unable found project #169

Closed SS-TT closed 6 years ago

SS-TT commented 6 years ago

Hi there, I'm trying to configure this plugin on my private GitLab server but I'm having some issues while running the Maven goal on a feature branch (it works for master).

This is the output:

Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.5.0.1254:sonar (default-cli) on project codec-manager: Failed to execute project builder: com.talanlabs.sonar.plugins.gitlab.CommitProjectBuilder: Unable found project for mygroup/myproject Verify Configuration sonar.gitlab.project_id or sonar.gitlab.user_token access project -> [Help 1]

sonar.gitlab.project_id was set to both http://myrepourl/mygroup/myproject and 579 with same results.

I also tried getting project details using GitLab's API and everything seems fine:

> curl http://myrepourl/api/v4/projects/mygroup%2Fmyproject?private_token=sonarQubeUserToken

StatusCode        : 200
StatusDescription : OK
Content           : {"id":579,"description":"","name":"myproject","name_with_namespace":"mygroup / myproject","path":"myproject","path_with_namespace":"mygroup/myproject","created_at..

...

Finally, this is the .gitlab-ci.yml file:


image: maven:latest

variables:
  MAVEN_CLI_OPTS: "-s .m2/settings.xml --batch-mode"
  MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"

cache:
  paths:
    - .m2/repository/
    - target/

sonarqube_master_job:
  stage: test
  only:
    - master
  script:
    - mvn $MAVEN_CLI_OPTS verify sonar:sonar -Dsonar.host.url=$SONAR_URL

sonarqube_preview_feature_job:
  stage: test
  only:
    - /^feature\/*/
  script:
    - git checkout origin/master
    - git config --global user.email "you@example.com"
    - git config --global user.name "Your Name"
    - git merge $CI_COMMIT_SHA --no-commit --no-ff
    - mvn $MAVEN_CLI_OPTS verify sonar:sonar -Dsonar.host.url=$SONAR_URL -Dsonar.analysis.mode=preview -Dsonar.gitlab.project_id=$CI_PROJECT_PATH -Dsonar.gitlab.commit_sha=$CI_COMMIT_SHA -Dsonar.gitlab.ref_name=$CI_COMMIT_REF_NAME

Any idea on what's going wrong?

twinguy commented 6 years ago

Hello, were you able to get this issue resolved. If so, could you share the resolution? I am seeing the same issue in my environment.

Thanks very much.

bartlibert commented 5 years ago

I had the same thing and found the cause: somebody had removed access for the user that I used for reporting. When I added it again, it worked. The message is cryptic though...