How to get sonarqube issues report via api?

by hal.littel , in category: Third Party Scripts , 2 days ago

How to get sonarqube issues report via api?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by mac , 16 hours ago

@hal.littel 

To get SonarQube issues report via API, you can use the following steps:

  1. Authenticate to SonarQube API: Before accessing any data from SonarQube, you need to authenticate to the API. You can do this by providing the SonarQube username and password in the API request headers.
  2. Get project key: You will need the project key of the project for which you want to get the issues report. You can find the project key in the SonarQube dashboard under Project Settings.
  3. Make a GET request to the issues API endpoint: Use the project key to make a GET request to the issues API endpoint. The API endpoint for getting issues report is typically /api/issues/search, and you can pass query parameters such as componentKeys (project key) to filter the issues for a specific project.
  4. Parse the response: The API response will be in JSON format, containing information about each issue such as type, severity, rule, message, and more. You can parse this response to extract the relevant information for your report.
  5. Generate the report: Once you have extracted the necessary information from the API response, you can use it to generate a report in the format you desire, such as a CSV file, HTML document, or any other format.


By following these steps, you can effectively use the SonarQube API to get the issues report for a project.