SonarQube Connector
SonarQube connector provides a Ballerina API to access the SonarQube REST API
Compatibility
Ballerina Language Version | API Version |
---|---|
0.990.3 | 6.7.2 |
Getting started
-
Refer Getting Strated Guide to download and install Ballerina.
-
To use SonarQube endpoint, you need to provide the following:
- SonarQube URL
- SonarQube token
Refer SonarQube API docuementation to obtain the above credentials.
-
Create a new Ballerina project by executing the following command.
<PROJECT_ROOT_DIRECTORY>$ ballerina init
-
Import the sonarqube module to your Ballerina project as follows.
import ballerina/config;
import ballerina/http;
import ballerina/io;
import wso2/sonarqube6;
string token = "your token";
string sonarqubeURL = "your sonarqube url";
sonarqube6:SonarQubeConfiguration sonarqubeConfig = {
baseUrl: sonarqubeURL,
clientConfig: {
auth: {
scheme: http:BASIC_AUTH,
username: token,
password: ""
}
}
};
sonarqube6:Client sonarqubeClient = new(sonarqubeConfig);
public function main() {
var projectDetails = sonarqubeClient->getProject(config:getAsString(PROJECT_NAME));
if (projectDetails is sonarqube6:Project) {
io:println("Project Details: ", projectDetails)
} else {
io:println("Error: ", projectDetails);
}
}