/module-sonarqube

Primary LanguageBallerinaApache License 2.0Apache-2.0

Build Status

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

  1. Refer Getting Strated Guide to download and install Ballerina.

  2. To use SonarQube endpoint, you need to provide the following:

    • SonarQube URL
    • SonarQube token

    Refer SonarQube API docuementation to obtain the above credentials.

  3. Create a new Ballerina project by executing the following command.

    <PROJECT_ROOT_DIRECTORY>$ ballerina init

  4. 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);
   }
}