[](https://github.com/SonarSource/orchestrator/actions/workflows/build.yml?query=branch%3Amaster)
# SonarQube Orchestrator
Orchestrator is a Java test library for installing and running SonarQube in integration tests. It provides JUnit 4 and JUnit 5 APIs for developers testing plugins and scanner integrations.
To learn more about the SonarQube product family, visit the [Sonar website](https://www.sonarsource.com/products/sonarqube/).
## 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`.
- `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]`.
Version aliases such as `DEV` and `LATEST_RELEASE` require a supported SonarSource Artifactory host:
`https://repox.jfrog.io`, `https://repox-internal.dev.sonar.build`, `https://repox-internal.sonar.build` or
`https://repox.sonar.build`. They will not work against a plain Maven repository URL (for example Maven Central).
Version alias resolution searches Artifactory with
`remote=1` so Edge Smart Remotes under `sonarsource-releases` / `sonarsource-builds` are included.
## 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 Artifactory
# Use a reader token issued for the configured SaaS or Edge instance.
# For SaaS, 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
# Fine-grained Personal access token used to request SonarSource development licenses at https://github.com/sonarsource/licenses.
# Generate a token from https://github.com/settings/personal-access-tokens/new
# The token needs `SonarSource` as the Resource Owner and Read-only access for the SonarSource/licenses repository.
# 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 (https://repox.jfrog.io/artifactory).
# Supported SonarSource hosts: repox.jfrog.io, repox-internal.dev.sonar.build,
# repox-internal.sonar.build and repox.sonar.build. These use authenticated
# Artifactory REST APIs with orchestrator.artifactory.accessToken / ARTIFACTORY_ACCESS_TOKEN.
# This property can be replaced by the environment variable ARTIFACTORY_URL.
# To use maven central instead, use https://repo1.maven.org/maven2
# To use a custom instance, use your own URL that points to a Maven repository
# (unauthenticated Maven layout client).
#orchestrator.artifactory.url=https://repo1.maven.org/maven2
For production Edge, configure `https://repox-internal.sonar.build/artifactory` for internal access or
`https://repox.sonar.build/artifactory` for public access, using production Edge reader credentials.
Choose the endpoint reachable from your runner. Existing dev Edge and SaaS endpoints remain supported.
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-2025 SonarSource Sàrl.
Licensed under the [GNU Lesser General Public License, Version 3.0](http://www.gnu.org/licenses/lgpl.txt)