Skip to content
No description, website, or topics provided.
Ballerina
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src/sonarqube
.gitignore
.travis.yml
Ballerina.lock
Ballerina.toml
LICENSE
README.md
issue_template.md
pull_request_template.md

README.md

Build Status

SonarQube Connector

SonarQube connector provides a Ballerina API to access the SonarQube REST API

Compatibility

Ballerina Language Version API Version
1.0.0 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/sonarqube;

string token = "your token";
string sonarqubeURL = "your sonarqube url";

sonarqube:SonarQubeBasicAuthProvider outboundBasicAuthProvider = new({
    username: token
});

http:BasicAuthHandler outboundBasicAuthHandler = new(outboundBasicAuthProvider);

sonarqube:SonarQubeConfiguration sonarqubeConfig = {
    baseUrl: sonarqubeURL,
    clientConfig: {
        auth: {
            authHandler: outboundBasicAuthHandler
        }
    }
};
   
sonarqube:Client sonarqubeClient = new(sonarqubeConfig);

public function main() {
   var projectDetails = sonarqubeClient->getProject(config:getAsString(PROJECT_NAME));
   if (projectDetails is sonarqube:Project) {
       io:println("Project Details: ", projectDetails);
   } else {
       io:println("Error: ", projectDetails);
   }
}
You can’t perform that action at this time.