diff --git a/integrations/sonarqube/CHANGELOG.md b/integrations/sonarqube/CHANGELOG.md index 8325cf2d0f..d65277563d 100644 --- a/integrations/sonarqube/CHANGELOG.md +++ b/integrations/sonarqube/CHANGELOG.md @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 +## 0.1.105 (2024-10-29) + + +### Bug Fixes + +- Fixed bug where issues/list API is not available for older SonarQube instance versions + + ## 0.1.104 (2024-10-23) diff --git a/integrations/sonarqube/client.py b/integrations/sonarqube/client.py index b7fb1edd09..ff0f5cf70c 100644 --- a/integrations/sonarqube/client.py +++ b/integrations/sonarqube/client.py @@ -38,8 +38,7 @@ class Endpoints: WEBHOOKS = "webhooks" MEASURES = "measures/component" BRANCHES = "project_branches/list" - ONPREM_ISSUES = "issues/list" - SAAS_ISSUES = "issues/search" + ISSUES_SEARCH = "issues/search" ANALYSIS = "activity_feed/list" PORTFOLIO_DETAILS = "views/show" PORTFOLIOS = "views/list" @@ -160,7 +159,7 @@ async def send_paginated_api_request( if ( e.response.status_code == 400 and query_params.get("ps", 0) > PAGE_SIZE - and endpoint in [Endpoints.ONPREM_ISSUES, Endpoints.SAAS_ISSUES] + and endpoint == Endpoints.ISSUES_SEARCH ): logger.error( "The request exceeded the maximum number of issues that can be returned (10,000) from SonarQube API. Consider using apiFilters in the config mapping to narrow the scope of your search. Returning accumulated issues and skipping further results." @@ -336,20 +335,17 @@ async def get_issues_by_component( """ component_issues = [] component_key = component.get("key") - endpoint_path = "" if self.is_onpremise: - query_params = {"project": component_key} - endpoint_path = Endpoints.ONPREM_ISSUES + query_params = {"components": component_key} else: query_params = {"componentKeys": component_key} - endpoint_path = Endpoints.SAAS_ISSUES if api_query_params: query_params.update(api_query_params) response = await self.send_paginated_api_request( - endpoint=endpoint_path, + endpoint=Endpoints.ISSUES_SEARCH, data_key="issues", query_params=query_params, ) diff --git a/integrations/sonarqube/pyproject.toml b/integrations/sonarqube/pyproject.toml index 12b267a712..8af17f201b 100644 --- a/integrations/sonarqube/pyproject.toml +++ b/integrations/sonarqube/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "sonarqube" -version = "0.1.104" +version = "0.1.105" description = "SonarQube projects and code quality analysis integration" authors = ["Port Team "]