Import project from GitLab with GitLab user

Hi everyone,

I am facing a strange “issue”, I am not sure if it is an issue or not, I have searched over this community and Google without any success.

I have installed a POC for SonarQube using docker, added GitLab ALM integration and it works as expected (I can connect to SonarQube using GitLab ).

When creating a project with “admin” user, I can import it with GitLab (with several steps as creating CI/CD var, etc). But when using “GitLab” account, I can only create project mannualy.

Am I missing something ? I would like to be able to import project from GitLab without giving admin right to all users :slight_smile:

  • Version CE : 8.9.1.44547
  • Database : 1.4.199 (2019-03-13)

Thank you for your help!

Jordan

Hi, welcome to the community forum!

Could you please clarify what you mean by “Gitlab” account? What are the SonarQube permissions of this account?

Hi Pierre,

Thank you for your feedback.

I have enabled the feature “GitLab Authentication”, then I am able to connect to SonarQube using GitLab account.

This user has “sonar-users” group and it cannot import project from GitLab. But if I change it to “sonar-administrator”, I can

Hi @pierreguillot ,

Do you have any update for me ?

Thank you for your help

Could you please log as admin, and show us what are the project creation permissions for the account you are trying to create a project from? (Including the groups it’s in)

Not sure if it is the right screenshot.

Global permission :

Project’s permission (created by “gitlab user” with “Add project with GitLab”

Your permissions seem about right, and I just gave it a try on a fresh instance and I can’t reproduce your issue.

When logged in with Gitlab, What does this API call produce? Is your Gitlab configuration visible here?

https://your.sonarqube.instance/api/alm_settings/list

I am using a fresh instance too (using docker) so I don’t know what I am missing. I have only configured GitLab integration and try to create a project.

Yes, API call is correct (I have removed url here)

{“almSettings”:[{“key”:“GitLab NXO”,“alm”:“gitlab”,“url”:“https://xxx.xxx.xx/api/v4”}]}

Do you have any groups syncing enable (between GitLab and Sonar) ?

Group sync don’t matter, as long as your user get the Create Project permission. @Philippe_Perrin or @Jeremy_Davis , do you think this issue could be in the UI only? I think the condition to display the menu is “there is a valid gitlab configuration + I have the permission to create a project”

As we can see in the screenshot you provided, the sonar-users group doesn’t have the Create projects permission. I’m not exactly sure how you created this user, but it probably has fallen into the default group with default permissions.

Yes but Anyone can create a project here.

What I have done so far :

  • Install Sonar with docker
  • Create API token in GitLab
  • Configure GitLab integration in Sonar
  • Log out from Sonar and connect with GitLab user (no manual creation done for this user, it was automatically created)
  • Create project with GitLab → all projects are displayed, but when configuring analysis, it only display manual configuration

I haven’t changed anything in role / user permission yet and I was thinking that all users were able to create (and configure) projects from GitLab using CI/CD.

If I want to configure analysis with CI/CD, I have to update project’s permissions and add “Administer” rights.

It won’t be very intuitive if an admin has to update each project and assign administer role

Could you clarify this sentence please? What make you think that you can’t import a project?

Screenshots will be better :slight_smile:

When creating a project from GitLab → select a project → “Set up” I have the following screen :

As admin, or when giving “Administer” role to project, I have the following screen :

My main question here is : how to have the previous screen (“With GitLab CI” option) when creating / importing a project from GitLab, with a “GitLab” user ?

You need admin permission at project level. So you need to change your permission template (Administration → Security → Permission Template), and tick Administer for Creators:

Keep in mind that by doing this, the project creator will become project admin of the created project.

Thank you @pierreguillot , it works as expected this way !

Thank you also for the warning, but it is the way projects will be manage

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