shijl0925 / python-sonarqube-api

Python Client library for interacting with Community, Developer, and Enterprise Editions SonarQube's REST APIs and SonarCloud's REST APIs.
https://python-sonarqube-pro-api.readthedocs.io/en/latest/
GNU Affero General Public License v3.0
133 stars 76 forks source link

How to get ALM setting key for sonarqube? #40

Open binbjz opened 2 years ago

binbjz commented 2 years ago

Hi, I want to get project name's git lab repository url, but I don't know how to get ALM setting key. Please help me, thanks! SonarQube Server Version: Community EditionVersion 8.9.3 (build 48735)

from sonarqube.enterprise import SonarEnterpriseClient

def sonar_ent_connector() -> SonarEnterpriseClient:
    sonarqube_ent_client = SonarEnterpriseClient(sonarqube_url=SQ_URL, token=SQ_TOKEN)
    sonar_ent_credential = sonarqube_ent_client.auth.check_credentials()

    if "true" not in sonar_ent_credential.lower():
        raise Exception("Permission authentication failure.")
    return sonarqube_ent_client

prj_key = "ABDevUtils"
sqe_connector.alm_integrations.search_gitlab_repos(almSettings="xxxx", projectName=prj_key)
binbjz commented 2 years ago

@shijl0925 Any updates for this questions ?

shijl0925 commented 2 years ago

how about use the create_gitlab fuction, such as:

almSettings = sonarqube_ent_client.alm_settings.create_gitlab(key, personalAccessToken, url)

binbjz commented 2 years ago
  1. I have configured sonarqube server and imported all projects from git lab. Do I still need to use “create_gitlab” to create almSettings ?
  2. For function "alm_settings.create_gitlab(key, personalAccessToken, url)" key – Unique key of the GitLab instance setting, I want to know how to get the GitLab instance setting, Where do I know where to get personalAccessToken and url.

Thank you very much. @shijl0925

binbjz commented 2 years ago

Hi, @shijl0925 Could you help me to resolve this question ? I would like to get gitlab project repository url by sonar project key. so, could you provide an example?

binbjz commented 2 years ago

Hi @shijl0925, Can you provide an example of how to use Sonar Key or Sonar Name to get its git project address?

timothestes commented 1 year ago

@binbjz were you able to figure out how to do this? Facing a similar problem.

skyheis commented 6 months ago

@binbjz @timothestes Hi all, I know it's a bit late, but the almSetting is actually the configuration name.

When you go here /admin/settings?category=almintegration&alm=gitlab is the first parameter in bold.