AmadeusITGroup / sonar-stash

Stash (BitBucket) plugin, a pull-request decorator which allows to integrate SonarQube violations directly into your pull-request
MIT License
165 stars 82 forks source link

unable to push SQ Analysis to Stash #37

Closed salustudy closed 8 years ago

salustudy commented 8 years ago

Hi , i have integrated SQ in eclipse i am trying to push SQ analysis to my stash using below command

sonar:sonar -Dsonar.analysis.mode=incremental -Dsonar.stash.notification -Dsonar.stash.project=CDC -Dsonar.stash.repository=cdc -Dsonar.stash.pullrequest.id=139 -Dsonar.stash.password=team

but i am getting [ERROR] [13:54:13.601] Unable to get SonarQube reviewer from Stash: Unable to retrieve user team. Received 401 with message Unauthorized. [ERROR] [13:54:13.601] Process stopped: no SonarQube reviewer identified to publish to Stash the SQ analysis N:B: team is my username and password to stash

Please correct me if i am using some wrong command

Thanks Salamat

acopet commented 8 years ago

Hello @salustudy,

It is a permission issue: authenticated user has insufficient permissions to view the SonarQube reviewer user. Could you please confirm the permissions of the "team" user?

Cheers, Antoine

salustudy commented 8 years ago

i am unable to get this SonarQube reviewer user in your statement could you please elaborate this ?

team user has STASH USER permission

Cheers Salamat

acopet commented 8 years ago

SonarQube reviewer is the user which pushes the SonarQube issues to Stash. It is the user defined from SonarQube configuration page (Stash base user).

This user needs to be authenticated and have:

salustudy commented 8 years ago

I tried with different user which has SYS.ADMIN privilege , but no luck!! same error . briefly writing what i did

  1. set up sonar server .
  2. integrated sonar-stash plugin (according to README )
  3. Added eclipse sonar plugin in eclipse .
  4. i checkout code from my stash repo ->after doing changes i raised pull request in stash-> That pull requst id i gave in maven build in step 4 (here i raised PR with both team and ADMIN ids)
  5. I ran my maven project using sonar:sonar -Dsonar.analysis.mode=incremental -Dsonar.stash.notification -Dsonar.stash.project=CDC -Dsonar.stash.repository=cdc -Dsonar.stash.pullrequest.id=144 -Dsonar.stash.password=adminUserPassword

Correct me if am doing something wrong or skipeed some steps . I am stuck here unable to proceed

Thanks Salamat

acopet commented 8 years ago

Hello @salustudy,

Installation part sounds good.

If I well remember you go through Stash version (2.10.1): After having a look to its REST api, this 401 error occurs when "The currently authenticated user has insufficient permissions to view the user". I really think problem comes from wrong Stash configuration...

We call the following REST method to get the user: /rest/api/1.0/users/{userSlug} (GET http verb). Could you please try to call manually this service and share the result?

salustudy commented 8 years ago

Hi Acopet , Hi have tried the rest service , i think i got proper response . Below is my response

{ "name": "team", "emailAddress": "itams@xxxx.com", "id": 152, "displayName": "Team", "active": true, "slug": "team", "link": { "url": "/users/team", "rel": "self" } }

Thanks Salamat

acopet commented 8 years ago

Ok, it is the expected result.

With which user did you make the REST call? What is the permission granted to this user? And could you please try the same REST call with user "Team"?

Cheers, Antoine

salustudy commented 8 years ago

i made REST call with Team user . This user has repo read permission .

acopet commented 8 years ago

Ok, retrieving the user should work with user team. Could you please run the SQ analysis with parameters -Dsonar.stash.login=team and -Dsonar.stash.password=< TEAM_PASSWORD > ?

In addition, to be able to approve a pull-request, team user needs to have REPO_WRITE permissions. Could you please update this?

And, last point: do you go through crowd group? In this case, like explained at the end of #35, you have to add team user to this group.

salustudy commented 8 years ago

i have tried but i got

i dint used crowd group .

acopet commented 8 years ago

Hello @salustudy,

Is this issue still relevant? Did you find out a solution?

Cheers, Antoine

smarkovik commented 8 years ago

Hello @acopet this issue is quite relevant for me. I am trying to use the same pl ugin, with our Stash instance. I had the SSL issue but I rebuilt from Pull request #46 which fixed this issue. After the rebuilt from the PR this issue was no longer present, however I now have this in my logs

` 01-Jan-1970 01:00:00 INFO: ANALYSIS SUCCESSFUL

01-Jan-1970 01:00:00 INFO: Executing post-job org.sonar.plugins.stash.StashIssueReportingPostJob

01-Jan-1970 01:00:00 ERROR: Unable to get SonarQube reviewer from Stash: Unable to retrieve user buildmanager. Received 404 with message Not Found.

01-Jan-1970 01:00:00 ERROR: Process stopped: no SonarQube reviewer identified to publish to Stash the SQ analysis

01-Jan-1970 01:00:00 INFO: ------------------------------------------------------------------------

01-Jan-1970 01:00:00 INFO: EXECUTION SUCCESS

01-Jan-1970 01:00:00 INFO: ------------------------------------------------------------------------`

I also confirm the user which is used in is has access to stash (read and write). I've even tried with admin privileges (for this user) any idea why this is happening ?