Show SonarQube on a component
Each annotated component shows its code quality: a Code Quality card on its Overview, and a SonarQube tab.
How to
1. Turn on the plugin
- In Administration, under PLATFORM, click Plugins.
- On the SonarQube card, turn on the Enable SonarQube switch.
If the card says Configure the SonarQube integration first, click it: the integration opens in Company connections. Add it (Add the SonarQube integration). The plugin turns on by itself when you save the integration: go to step 2.
2. Annotate the component
In the component's catalog-info.yaml, add the key of its SonarQube project:
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
name: shop-api
annotations:
sonarqube.org/project-key: acme-shop-api
spec:
type: service
lifecycle: production
owner: team-a
In SonarQube, open the project, then Project Information: it is the Project Key.
3. Check
Open the component in Catalog:
- on Overview, the Code Quality card shows the quality gate, Bugs, Vulnerabilities, Code Smells, Hotspots Reviewed, Coverage and Duplications;
- the SonarQube tab shows the same figures.
✅ Done.
You have several SonarQube
Start the annotation with the instance key of the integration, then /, then the project key:
metadata:
annotations:
sonarqube.org/project-key: prod/acme-shop-api
Here, prod is the SonarQube instance key of the production SonarQube integration.
What it shows, and to whom
Anyone who can open the component sees its code quality. Astrolabe reads SonarQube with the token of the integration, the same for every reader.
Something is wrong? See Common problems with SonarQube.