Search in sources :

Example 1 with TriggersConfig

use of hudson.plugins.sonar.model.TriggersConfig in project configuration-as-code-plugin by jenkinsci.

the class SonarQubeTest method configure_sonar_globalconfig.

@Test
@ConfiguredWithReadme("sonarqube/README.md")
public void configure_sonar_globalconfig() {
    final SonarGlobalConfiguration configuration = GlobalConfiguration.all().get(SonarGlobalConfiguration.class);
    assertTrue(configuration.isBuildWrapperEnabled());
    final SonarInstallation installation = configuration.getInstallations()[0];
    assertEquals("TEST", installation.getName());
    assertEquals("http://url:9000", installation.getServerUrl());
    assertEquals("token", installation.getCredentialsId());
    assertEquals("mojoVersion", installation.getMojoVersion());
    assertEquals("additionalAnalysisProperties", installation.getAdditionalAnalysisProperties());
    final TriggersConfig triggers = installation.getTriggers();
    assertTrue(triggers.isSkipScmCause());
    assertTrue(triggers.isSkipUpstreamCause());
    assertEquals("envVar", triggers.getEnvVar());
}
Also used : SonarGlobalConfiguration(hudson.plugins.sonar.SonarGlobalConfiguration) SonarInstallation(hudson.plugins.sonar.SonarInstallation) TriggersConfig(hudson.plugins.sonar.model.TriggersConfig) Test(org.junit.Test) ConfiguredWithReadme(io.jenkins.plugins.casc.misc.ConfiguredWithReadme)

Example 2 with TriggersConfig

use of hudson.plugins.sonar.model.TriggersConfig in project sonar-scanner-jenkins by SonarSource.

the class SonarBuildWrapperTest method maskAuthToken.

@Test
public void maskAuthToken() throws IOException, InterruptedException {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    configureSonar(new SonarInstallation("local", "http://localhost:9001", MYTOKEN, null, null, new TriggersConfig(), null));
    OutputStream os = wrapper.decorateLogger(mock(AbstractBuild.class), bos);
    IOUtils.write("test sonar\ntest mytoken\n", os);
    assertThat(new String(bos.toByteArray())).isEqualTo("test sonar\ntest ******\n");
}
Also used : AbstractBuild(hudson.model.AbstractBuild) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) TriggersConfig(hudson.plugins.sonar.model.TriggersConfig) Test(org.junit.Test)

Example 3 with TriggersConfig

use of hudson.plugins.sonar.model.TriggersConfig in project sonar-scanner-jenkins by SonarSource.

the class SonarInstallationTest method testRoundtrip.

@Test
public void testRoundtrip() throws IOException {
    TriggersConfig triggers = new TriggersConfig();
    SonarGlobalConfiguration d = new SonarGlobalConfiguration();
    d.setInstallations(new SonarInstallation("Name", "server.url", "token", "mojoVersion", "props", triggers, "key=value"));
    d.save();
    SonarInstallation i = new SonarGlobalConfiguration().getInstallations()[0];
    String storedConfig = Util.loadFile(new File(Jenkins.getInstance().getRootDir(), d.getId() + ".xml"));
    assertThat(i.getName()).isEqualTo("Name");
    assertThat(i.getServerUrl()).isEqualTo("server.url");
    assertThat(i.getServerAuthenticationToken()).isEqualTo("token");
    assertThat(i.getMojoVersion()).isEqualTo("mojoVersion");
    assertThat(i.getAdditionalProperties()).isEqualTo("props");
    assertThat(i.getAdditionalAnalysisProperties()).isEqualTo("key=value");
    assertThat(storedConfig).doesNotContain("dbPasswd");
    assertThat(storedConfig).doesNotContain("sonarPasswd");
}
Also used : File(java.io.File) TriggersConfig(hudson.plugins.sonar.model.TriggersConfig) Test(org.junit.Test)

Aggregations

TriggersConfig (hudson.plugins.sonar.model.TriggersConfig)3 Test (org.junit.Test)3 AbstractBuild (hudson.model.AbstractBuild)1 SonarGlobalConfiguration (hudson.plugins.sonar.SonarGlobalConfiguration)1 SonarInstallation (hudson.plugins.sonar.SonarInstallation)1 ConfiguredWithReadme (io.jenkins.plugins.casc.misc.ConfiguredWithReadme)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 OutputStream (java.io.OutputStream)1