MR decoration with gitlab

I have a project in Gitlab with the following script in the .yml file which is running on MR only
- sonar-scanner -Dsonar.host.url="$SONAR_BASE_URL" -Dsonar.login="$SONAR_LOGIN_TOKEN" -Dsonar.coverageReportPaths=sonarqube-generic-coverage.xml -Dsonar.pullrequest.key="${CI_MERGE_REQUEST_IID}" -Dsonar.pullrequest.base="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}" -Dsonar.pullrequest.branch="${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME}"

when I run it, I get this warning in sonarcloud:

Pull request decoration did not happen. Property 'sonar.pullrequest.provider' was missing.

And following other threads in this community I can’t see the option of gitlab in the list of providers when I go to the settings of my project. Image attached

Any clue how I can use gitlab as provider?

Thanks in advance

Marcos

Hi @marcosmartinezfx and welcome to the community !

Just add -Dsonar.pullrequest.provider=“gitlab” , you should be good to go then.

HTH,
Mickaël

Thanks @mickaelcaro for your answer. I tried that and it didn’t work, I have this warning now:

Pull request decoration did not happen. Unable to find a Pull Request decorator for provider ‘“gitlab”’.

Ah, you may need to removed the double quotes then (as per the warning, looks like they’ve been considered as part of the provider name)

At least without double quotes I don’t see any warning, but I don’t see anything in my MR. Should I see something in the pipeline log?

@mickaelcaro any clue why I don’t see anything in my MR? Thanks in advance

Hi @marcosmartinezfx,

Apologies for delayed answer. Can you tell me if your organization is bound to GitLab?
You should see the GitLab icon next to your org name:

image

The same icon you should see next to your projects:

image

Let me know.

Best,
Marcin

Hi @Marcin_Majewski I have a mix of both, as you can see the group overview seems to be linked but not the project itself. Screenshot attached

Group overview linked

Project not linked
Screenshot 2021-04-05 at 11.30.02

How do I link the project too?

Thanks in advance

Marcos Martínez

Hi @marcosmartinezfx,

Unfortunately, it is currently not possible to link the existing project. You would have to re-create it. You can do this by clicking “+” icon on top-right side of the screen and selecting existing project from the list as seen here (projects annotated with GitLab logo):

image

Best,
Marcin

Thanks @Marcin_Majewski I just imported a new repository and I have the icon which is good, but I ran an analysis from a MR and despite everything looks fine in sonarcloud, I don’t see the results printed in my MR

Any idea why I don’t get any feedback in my MR?

Thanks

Marcos Martínez

Hey,

Can you provide me with background task id of this analysis? You can find it in Administration → Background task. I will check it out

Best,
Marcin

Sure, this is the task ID of my last execution: AXim5Zr3lVrKDeU4Feb3

Regards

Marcos Martínez

Can you tell me what kind of permissions does your token have? It seems that your token does not have permission to post a note in the merge request.

Best,
Marcin

I’m afraid I can’t tell you because I didn’t create that token and I don’t have access to it but I’m trying to update the token to confirm if that’s the problem but I get this error when I try to update the token

Regards

Marcos Martínez

Are you creating the token as the member of the same organization that is bound in SonarCloud? Can you double-check that?

Best,
Marcin

I’m updating it here:

Is this the correct place?

Regards

Marcos Martínez

Yes, you are doing it in the right place. Sorry, I was not clear enough in my previous post.

How do you generate the token? Do you generate this token yourself? In other words: when you are logged in GitLab and generate the token, you are logged in the same way as you are logged in the SonarCloud?

Best,
Marcin

Yes, actually we are using gitlab login for sonar cloud. I see this error in the console if that helps:

Regards

Marcos Martínez

Problem has been solved in the private thread. There were two problems: token was invalid and user was not a member of the group that was imported in SonarCloud.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.