Search in sources :

Example 11 with ConfiguredWithReadme

use of io.jenkins.plugins.casc.misc.ConfiguredWithReadme in project configuration-as-code-plugin by jenkinsci.

the class GiteaServerTest method configure_gitea.

@Test
@ConfiguredWithReadme("gitea/README.md")
public void configure_gitea() {
    final GiteaServers configuration = GlobalConfiguration.all().get(GiteaServers.class);
    assertEquals(configuration.getServers().size(), 1);
    GiteaServer config = configuration.getServers().get(0);
    assertEquals("https://my-scm-url", config.getServerUrl());
    assertEquals("<my-credential-id>", config.getCredentialsId());
    assertEquals("scm", config.getDisplayName());
    assertTrue(config.isManageHooks());
}
Also used : GiteaServers(org.jenkinsci.plugin.gitea.servers.GiteaServers) GiteaServer(org.jenkinsci.plugin.gitea.servers.GiteaServer) Test(org.junit.Test) ConfiguredWithReadme(io.jenkins.plugins.casc.misc.ConfiguredWithReadme)

Example 12 with ConfiguredWithReadme

use of io.jenkins.plugins.casc.misc.ConfiguredWithReadme in project configuration-as-code-plugin by jenkinsci.

the class JenkinsReadmeDemoTest method configure_demo_first_code_block.

@Test
@ConfiguredWithReadme("jenkins/README.md#0")
public void configure_demo_first_code_block() {
    final Jenkins jenkins = Jenkins.get();
    assertEquals("Jenkins configured automatically by Jenkins Configuration as Code plugin\n\n", jenkins.getSystemMessage());
    assertEquals(5, jenkins.getNumExecutors());
    assertEquals(2, jenkins.getScmCheckoutRetryCount());
    assertEquals(Mode.NORMAL, jenkins.getMode());
}
Also used : Jenkins(jenkins.model.Jenkins) Test(org.junit.Test) ConfiguredWithReadme(io.jenkins.plugins.casc.misc.ConfiguredWithReadme)

Example 13 with ConfiguredWithReadme

use of io.jenkins.plugins.casc.misc.ConfiguredWithReadme in project configuration-as-code-plugin by jenkinsci.

the class JenkinsReadmeDemoTest method configure_demo_second_code_block.

@Test
@ConfiguredWithReadme("jenkins/README.md#1")
public void configure_demo_second_code_block() {
    final Jenkins jenkins = Jenkins.get();
    assertThat(jenkins.getSystemMessage(), containsString("Welcome to our build server."));
    assertEquals(1, jenkins.getNumExecutors());
}
Also used : Jenkins(jenkins.model.Jenkins) Test(org.junit.Test) ConfiguredWithReadme(io.jenkins.plugins.casc.misc.ConfiguredWithReadme)

Example 14 with ConfiguredWithReadme

use of io.jenkins.plugins.casc.misc.ConfiguredWithReadme in project configuration-as-code-plugin by jenkinsci.

the class MavenConfiguratorTest method configure_maven_global_config_specific_files.

@Test
@ConfiguredWithReadme("maven/README.md#2")
public void configure_maven_global_config_specific_files() {
    final GlobalMavenConfig descriptor = ExtensionList.lookupSingleton(GlobalMavenConfig.class);
    assertThat(descriptor.getGlobalSettingsProvider(), instanceOf(FilePathGlobalSettingsProvider.class));
    FilePathGlobalSettingsProvider globalProvider = (FilePathGlobalSettingsProvider) descriptor.getGlobalSettingsProvider();
    assertThat(globalProvider.getPath(), is("/conf/maven/global-settings.xml"));
    assertThat(descriptor.getSettingsProvider(), instanceOf(FilePathSettingsProvider.class));
    FilePathSettingsProvider provider = (FilePathSettingsProvider) descriptor.getSettingsProvider();
    assertThat(provider.getPath(), is("/conf/maven/settings.xml"));
}
Also used : GlobalMavenConfig(jenkins.mvn.GlobalMavenConfig) FilePathGlobalSettingsProvider(jenkins.mvn.FilePathGlobalSettingsProvider) FilePathSettingsProvider(jenkins.mvn.FilePathSettingsProvider) Test(org.junit.Test) ConfiguredWithReadme(io.jenkins.plugins.casc.misc.ConfiguredWithReadme)

Example 15 with ConfiguredWithReadme

use of io.jenkins.plugins.casc.misc.ConfiguredWithReadme in project configuration-as-code-plugin by jenkinsci.

the class MavenConfiguratorTest method export_maven_global_config_specific_files.

@Test
@ConfiguredWithReadme("maven/README.md#2")
public void export_maven_global_config_specific_files() throws Exception {
    ConfiguratorRegistry registry = ConfiguratorRegistry.get();
    ConfigurationContext context = new ConfigurationContext(registry);
    CNode yourAttribute = getToolRoot(context).get("mavenGlobalConfig");
    String exported = toYamlString(yourAttribute);
    String expected = toStringFromYamlFile(this, "MavenConfiguratorTestGlobalConfigSpecificFilesExpected.yml");
    assertThat(exported, is(expected));
}
Also used : CNode(io.jenkins.plugins.casc.model.CNode) Util.toYamlString(io.jenkins.plugins.casc.misc.Util.toYamlString) Test(org.junit.Test) ConfiguredWithReadme(io.jenkins.plugins.casc.misc.ConfiguredWithReadme)

Aggregations

ConfiguredWithReadme (io.jenkins.plugins.casc.misc.ConfiguredWithReadme)46 Test (org.junit.Test)46 Jenkins (jenkins.model.Jenkins)12 User (hudson.model.User)3 LDAPSecurityRealm (hudson.security.LDAPSecurityRealm)3 SecurityRealm (hudson.security.SecurityRealm)3 InstallSourceProperty (hudson.tools.InstallSourceProperty)3 BasicSSHUserPrivateKey (com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey)2 StandardUsernamePasswordCredentials (com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials)2 DockerCloud (com.nirima.jenkins.plugins.docker.DockerCloud)2 DockerTemplate (com.nirima.jenkins.plugins.docker.DockerTemplate)2 HudsonPrivateSecurityRealm (hudson.security.HudsonPrivateSecurityRealm)2 Util.toYamlString (io.jenkins.plugins.casc.misc.Util.toYamlString)2 CNode (io.jenkins.plugins.casc.model.CNode)2 AWSCredentialsImpl (com.cloudbees.jenkins.plugins.awscredentials.AWSCredentialsImpl)1 DirectEntryPrivateKeySource (com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey.DirectEntryPrivateKeySource)1 Credentials (com.cloudbees.plugins.credentials.Credentials)1 SecretBytes (com.cloudbees.plugins.credentials.SecretBytes)1 SystemCredentialsProvider (com.cloudbees.plugins.credentials.SystemCredentialsProvider)1 UsernamePasswordCredentials (com.cloudbees.plugins.credentials.common.UsernamePasswordCredentials)1