Quick Start
This document will help you quickly understand how to create a SonarQube connector to connect to a SonarQube instance and perform code quality analysis securely without directly handling authentication tokens.
We will create a SonarQube connector and use it to execute sonar-scanner for code analysis without directly handling credentials on the client side.
TOC
Estimated Reading TimePrerequisitesProcess OverviewSteps to OperateStep 1: Create NamespaceStep 2: Create SonarQube Token and ConnectorStep 3: Create a Job to Perform Code AnalysisCleanupWhat's NextEstimated Reading Time
15 minutes
Prerequisites
- Kubernetes cluster with Connectors system installed (Operator, ConnectorsCore and ConnectorsSonarQube components). See the Installation Guide for details on installing these components.
- SonarQube instance address (SonarQube server) and authentication token
- Basic knowledge of Kubernetes and SonarQube
- A project to analyze (source code)
Process Overview
Steps to Operate
Step 1: Create Namespace
Create a dedicated namespace for this demonstration:
Step 2: Create SonarQube Token and Connector
Create both the Secret containing SonarQube authentication token and the SonarQube connector resource.
For more detailed information about creating and configuring connectors, please refer to the Connectors Quick Start Guide.
Verify that the connector is in "Ready" status:
The output should show:
Step 3: Create a Job to Perform Code Analysis
Create a Kubernetes job that uses the connector to perform SonarQube scanning:
The connector mounts a sonar-project.properties configuration file via CSI that contains scanner settings with proxy configuration. The configuration includes:
sonar.host.url: SonarQube server addresssonar.scanner.proxyHost: Proxy hostname for secure accesssonar.scanner.proxyPort: Proxy portsonar.scanner.proxyUser: Proxy authentication usernamesonar.scanner.proxyPassword: Proxy authentication password (token)
If your sonar-project.properties file already contains sonar.scanner.proxy* or sonar.host.url properties, remove them to avoid conflicts with the connector-provided configuration.
Verify the job execution:
The output should show successful analysis results:
Cleanup
After completing the demonstration, clean up the resources:
What's Next
- Learn about SonarQube ConnectorClass to understand the connector configuration in detail
- Explore How-to Guides for advanced usage scenarios
- Check Troubleshooting if you encounter any issues