SonarQube icon

SonarQube

Interact with SonarQube or SonarCloud API

Actions3

Overview

This node integrates with the SonarQube or SonarCloud API to perform various operations related to code quality metrics and components. Specifically, for the Components - Search operation, it allows users to search for components within a specified organization in SonarQube. This is useful for retrieving lists of projects, modules, or other components that exist in the SonarQube instance, optionally filtered by a search query.

Common scenarios include:

  • Fetching all components available in an organization to analyze or report on their status.
  • Searching for specific components by name or partial match using a query string.
  • Paginating through large sets of components or fetching all at once via automatic pagination.

Practical example:

  • A user wants to get a list of all components in their organization to monitor their code quality trends or to feed this data into another workflow for further processing.

Properties

Name Meaning
Page (p) The page number of results to retrieve (minimum 1).
Page Size (ps) Number of components per page (minimum 1, maximum 500).
Get All? (scroll) Whether to fetch all records automatically by paginating through all pages.
Organization The identifier of the organization in SonarQube whose components are being searched.
Search Query (q) Optional text query to filter components by name or other searchable fields.

Output

The output JSON contains the response from the SonarQube API's components search endpoint. It typically includes:

  • components: An array of component objects matching the search criteria.
  • Pagination metadata such as current page, page size, total count, etc.

Each component object generally includes details like component key, name, qualifier, visibility, and other metadata relevant to the component.

If binary data were involved (not applicable here), it would be summarized accordingly, but this node outputs only JSON data.

Dependencies

  • Requires an active connection to a SonarQube or SonarCloud instance.
  • Needs an API authentication token credential configured in n8n to authorize requests.
  • Uses internal helper functions to handle API requests and pagination.

Troubleshooting

  • Common issues:

    • Invalid or missing organization parameter will cause the API call to fail.
    • Insufficient permissions or invalid API token may result in authorization errors.
    • Requesting too large a page size might be rejected by the API; keep within allowed limits.
    • Network connectivity problems can cause request failures.
  • Error messages:

    • Authorization errors usually indicate invalid or expired API credentials.
    • "Item index" errors point to which input item caused the failure, helpful when processing multiple items.
    • If automatic pagination (Get All?) is enabled but the API does not support it properly, incomplete data may be returned.

To resolve errors:

  • Verify the organization name is correct.
  • Ensure the API token has sufficient permissions.
  • Adjust page size or disable automatic pagination if encountering timeouts or memory issues.
  • Check network connectivity and API availability.

Links and References

Discussion