Giter Site home page Giter Site logo

sonarsource / orchestrator Goto Github PK

View Code? Open in Web Editor NEW
9.0 22.0 6.0 10.97 MB

Java library for running SonarQube in tests

License: GNU Lesser General Public License v3.0

Java 99.84% HTML 0.01% Shell 0.07% Batchfile 0.07% Starlark 0.02%
sonarqube

orchestrator's Introduction

Build Status Quality Gate

Orchestrator is a Java library to install and run SonarQube from tests.

JUnit 4 API

An instance of class com.sonar.orchestrator.junit4.OrchestratorRule can be used as Rule or ClassRule. It will represent a SonarQube server that will be started before tests, and stopped after:

public class MyTest {

    @ClassRule
    public static OrchestratorRule ORCHESTRATOR = OrchestratorRule.builderEnv()
      .setSonarVersion("7.0")
      .addPlugin(FileLocation.of("/path/to/plugin.jar"))
      .addPlugin(MavenLocation.of("org.sonarsource.java", "sonar-java-plugin", "5.2.0.13398")
      .setServerProperty("sonar.web.javaOpts", "-Xmx1G")
      .build();

    @Test
    public void myTest() {
        // run SonarQube Scanner
        ORCHESTRATOR.executeBuild(SonarScanner.create(new File("/path/to/project")));

        // requests web services
        String baseUrl = ORCHESTRATOR.getServer().getUrl();
        // ...
    }

}

JUnit 5 API

An instance of class com.sonar.orchestrator.junit5.OrchestratorExtension can be used as Extension. It will represent a SonarQube server that will be started before tests, and stopped after:

class MyTests {

    @RegisterExtension
    static OrchestratorExtension ORCHESTRATOR = OrchestratorExtension.builderEnv()
      .setSonarVersion("7.0")
      .addPlugin(FileLocation.of("/path/to/plugin.jar"))
      .addPlugin(MavenLocation.of("org.sonarsource.java", "sonar-java-plugin", "5.2.0.13398")
      .setServerProperty("sonar.web.javaOpts", "-Xmx1G")
      .build();

    @Test
    void myTest() {
        // run SonarQube Scanner
        ORCHESTRATOR.executeBuild(SonarScanner.create(new File("/path/to/project")));

        // requests web services
        String baseUrl = ORCHESTRATOR.getServer().getUrl();
        // ...
    }

}

Version Aliases

Aliases can be used to define the versions of SonarQube and plugins to be installed. Supported values are:

  • DEV for the latest official build (in terms of version number, not date)
  • DEV[x.y] for the latest official build of a series. For example DEV[5.2] may install version 5.2.0.1234.
  • DOGFOOD for the latest build of dogfood branch
  • DOGFOOD[x.y] for the latest build of a series in dogfood branch
  • LATEST_RELEASE for the latest release (in terms of version number, not date)
  • LATEST_RELEASE[x.y] for the latest release of a series, for example LATEST_RELEASE[5.2]

The alias LTS is no more supported for SonarQube since Orchestrator 3.17. It should be replaced by LATEST_RELEASE[6.7].

Local Cache

The artifacts downloaded from Artifactory (SonarQube, plugins) are copied to the local directory ~/.sonar/orchestrator/cache. This directory is not automatically purged and may grow significantly when using the version alias DEV.

Configuration

The test environment is configured in the file ~/.sonar/orchestrator/orchestrator.properties:

# Token used to download SonarSource private artifacts from https://repox.jfrog.io/repox
# Generate your identity token at https://repox.jfrog.io/ui/user_profile
# This property can be replaced by the environment variable ARTIFACTORY_ACCESS_TOKEN.
#orchestrator.artifactory.accessToken=xxx

# Personal access token used to request SonarSource development licenses at https://github.com/sonarsource/licenses.
# Generate a token from https://github.com/settings/tokens
# This property can be replaced by the environment variable GITHUB_TOKEN.
#github.token=xxx

# Port of SonarQube server. Default value is 0 (random).
#orchestrator.container.port=10000

# Maven installation, used when running Scanner for Maven.
# By default Maven binary is searched in $PATH
#maven.home=/usr/local/Cellar/maven/3.5.0/libexec

# Maven local repository (optional), used to search artifacts of plugins before
# downloading from Artifactory.
# Default is ~/.m2/repository
#maven.localRepository=/path/to/maven/repository

# Instance of Artifactory. Default is SonarSource's instance.
# This property can be replaced by the environment variable ARTIFACTORY_URL.
#orchestrator.artifactory.url=https://repox.jfrog.io/repox

The path to configuration file can be overridden with the system property orchestrator.configUrl or the environment variable ORCHESTRATOR_CONFIG_URL. Example: -Dorchestrator.configUrl=file:///path/to/orchestrator.properties

HTTP Proxy

For running Orchestrator behind a corporate proxy, add Java properties :

-Dhttp.proxyHost=proxy.company.com
-Dhttp.proxyPort=80
-Dhttps.proxyHost=proxy.company.com
-Dhttps.proxyPort=80
-Dhttp.nonProxyHosts="localhost|127.0.0.1|*.company.com"
-Dhttp.proxyUser=foo
-Dhttp.proxyPassword=bar

License

Copyright 2011-2024 SonarSource.

Licensed under the GNU Lesser General Public License, Version 3.0

orchestrator's People

Contributors

alain-kermis-sonarsource avatar antoine-vigneau-sonarsource avatar axel3rd avatar belen-pruvost-sonarsource avatar costin-zaharia-sonarsource avatar dbmeneses avatar dependabot[bot] avatar dgageot avatar drautureau-sonarsource avatar ehartmann avatar ericg138 avatar gyula-sallai-sonarsource avatar henryju avatar jacek-poreda-sonarsource avatar julien-carsique-sonarsource avatar julienlancelot avatar lukasz-jarocki-sonarsource avatar malena-ebert-sonarsource avatar matteo-mara-sonarsource avatar michal-duda-sonarsource avatar pierre-guillot-gh avatar sns-seb avatar stanislavhh avatar steve-marion-sonarsource avatar teryk avatar tomverin avatar vlad-sonar avatar wohops avatar wouter-admiraal-sonarsource avatar xavierbourguignon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.