Finding Empty portfolios for remediation

Hi,

We are currently using SonarQube 9.9 LTS and we have ~1000 portfolios. Among them ~200 are portfolios with empty projects. We want to address this via an automation.

Is there any way to identify whether a portfolio is something with empty projects? Any APIs or database query available to get the data?

At the moment, as an alternative, I am using the API call https://sonarqube.org.net/api/measures/search_history?component=portfolio_key&metrics=coverage to find the coverage for the portfolio_key and if the result doesn’t has any data, it can be considered as an empty portfolio. Is this a correct approach?

Appreciate your help!

Thanks.

Hey @IamGuna

Can you clarify whether or not you’re trying to find:

  • Portfolios that have never been computed
  • Portfolios that contain 0 projects
  • Portfolios that only contain projects with 0 lines of code

Hi @Colin

We have portfolios with projects associated to it and everyday portfolios are being recomputed. However, the main branch of many projects were not scanned / developers having different branches as their release branch and those branches were not selected in the portfolio. 200+ portfolios were just created and the branches were not mapped properly. Hence resulted portfolios with empty projects. We want to consolidate such portfolios to follow-up with corresponding app teams to ensure the mappings are available properly. Hence, we need an approach to identify such portfolios.

Found the solution - with the help of Sonar support team.

The following API call helped me to find the portfolios only with empty projects - api/measures/component?component=non_empty_portfolio&metricKeys=ncloc

The measures component will be an empty array if a portfolio only have empty projects.

{
    "component": {
        "key": "portfolio_key",
        "name": "portfolio_name",
        "qualifier": "VW",
        "measures": []
    }
}

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