Search in sources :

Example 6 with SonarScanner

use of com.sonar.orchestrator.build.SonarScanner in project sonarqube by SonarSource.

the class IssuesModeTest method configureRunner.

private SonarScanner configureRunner(String projectDir, String... props) throws IOException {
    SonarScanner runner = SonarScanner.create(ItUtils.projectDir(projectDir), "sonar.working.directory", temp.newFolder().getAbsolutePath(), "sonar.report.export.path", "sonar-report.json", "sonar.userHome", temp.newFolder().getAbsolutePath());
    runner.setProperties(props);
    return runner;
}
Also used : SonarScanner(com.sonar.orchestrator.build.SonarScanner)

Example 7 with SonarScanner

use of com.sonar.orchestrator.build.SonarScanner in project sonarqube by SonarSource.

the class PermissionTest method scanner_fails_if_authentication_token_is_not_valid.

@Test
public void scanner_fails_if_authentication_token_is_not_valid() {
    SonarScanner sampleProject = SonarScanner.create(projectDir("shared/xoo-sample"));
    sampleProject.setProperties("sonar.login", "unknown-token", "sonar.password", "");
    BuildResult buildResult = orchestrator.executeBuildQuietly(sampleProject);
    assertThat(buildResult.isSuccess()).isFalse();
}
Also used : BuildResult(com.sonar.orchestrator.build.BuildResult) SonarScanner(com.sonar.orchestrator.build.SonarScanner) Test(org.junit.Test)

Example 8 with SonarScanner

use of com.sonar.orchestrator.build.SonarScanner in project sonarqube by SonarSource.

the class CrossModuleDuplicationsTest method analyzeProject.

private static SonarScanner analyzeProject(File projectDir, String projectKey, boolean create, String... additionalProperties) {
    if (create) {
        orchestrator.getServer().provisionProject(projectKey, projectKey);
        orchestrator.getServer().associateProjectToQualityProfile(projectKey, "xoo", "xoo-duplication-profile");
    }
    SonarScanner sonarRunner = SonarScanner.create(projectDir);
    ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
    for (int i = 0; i < additionalProperties.length; i += 2) {
        builder.put(additionalProperties[i], additionalProperties[i + 1]);
    }
    SonarScanner scan = sonarRunner.setDebugLogs(true).setProperties(builder.build());
    orchestrator.executeBuild(scan);
    return scan;
}
Also used : ImmutableMap(com.google.common.collect.ImmutableMap) SonarScanner(com.sonar.orchestrator.build.SonarScanner)

Example 9 with SonarScanner

use of com.sonar.orchestrator.build.SonarScanner in project sonarqube by SonarSource.

the class PluginsTest method preview_analysis_of_project_with_all_supported_languages.

@Test
public void preview_analysis_of_project_with_all_supported_languages() {
    SonarScanner analysis = newAnalysis();
    analysis.setProperty("sonar.analysis.mode", "issues");
    BuildResult result = ORCHESTRATOR.executeBuildQuietly(analysis);
    if (result.getLastStatus() != 0) {
        fail(result.getLogs());
    }
}
Also used : BuildResult(com.sonar.orchestrator.build.BuildResult) SonarScanner(com.sonar.orchestrator.build.SonarScanner) Test(org.junit.Test)

Example 10 with SonarScanner

use of com.sonar.orchestrator.build.SonarScanner in project sonarqube by SonarSource.

the class PluginsTest method newAnalysis.

private static SonarScanner newAnalysis() {
    SonarScanner analysis = SonarScanner.create(Project.basedir());
    // required to bypass usage of build-wrapper
    analysis.setProperties("sonar.cfamily.build-wrapper-output.bypass", "true");
    return analysis;
}
Also used : SonarScanner(com.sonar.orchestrator.build.SonarScanner)

Aggregations

SonarScanner (com.sonar.orchestrator.build.SonarScanner)84 Test (org.junit.Test)65 BuildResult (com.sonar.orchestrator.build.BuildResult)38 File (java.io.File)21 QualityGate (org.sonar.wsclient.qualitygate.QualityGate)8 JSONArray (org.json.simple.JSONArray)4 JSONObject (org.json.simple.JSONObject)4 Issue (org.sonar.wsclient.issue.Issue)4 Favorites (org.sonarqube.ws.Favorites)3 SearchRequest (org.sonarqube.ws.client.favorite.SearchRequest)3 Path (java.nio.file.Path)2 ArrayList (java.util.ArrayList)2 BeforeClass (org.junit.BeforeClass)2 SonarClient (org.sonar.wsclient.SonarClient)2 IssueClient (org.sonar.wsclient.issue.IssueClient)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 WebTestSuite.createSonarScanner (com.sonar.it.web.WebTestSuite.createSonarScanner)1 BuildFailureException (com.sonar.orchestrator.build.BuildFailureException)1 SonarScannerInstaller (com.sonar.orchestrator.build.SonarScannerInstaller)1 FileSystem (com.sonar.orchestrator.config.FileSystem)1