hudson.tools.InstallSourceProperty Java Examples

The following examples show how to use hudson.tools.InstallSourceProperty. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JdkConfiguratorTest.java    From configuration-as-code-plugin with MIT License 6 votes vote down vote up
@Test
public void configure_jdk_tool() {
    final JDK.DescriptorImpl descriptor = ExtensionList.lookupSingleton(JDK.DescriptorImpl.class);
    assertEquals(1, descriptor.getInstallations().length);

    JDK jdk = descriptor.getInstallations()[0];
    assertEquals("jdk8", jdk.getName());
    assertEquals("/jdk", jdk.getHome());

    InstallSourceProperty installSourceProperty = jdk.getProperties().get(InstallSourceProperty.class);
    assertEquals(1, installSourceProperty.installers.size());

    JDKInstaller installer = installSourceProperty.installers.get(JDKInstaller.class);
    assertEquals("jdk-8u181-oth-JPR", installer.id);
    assertTrue(installer.acceptLicense);
}
 
Example #2
Source File: GitToolResolverTest.java    From git-client-plugin with MIT License 6 votes vote down vote up
@Test
public void shouldResolveToolsOnMaster() throws Exception {
    final String label = "master";
    final String command = "echo Hello";
    final String toolHome = "TOOL_HOME";
    AbstractCommandInstaller installer = isWindows()
            ? new BatchCommandInstaller(label, command, toolHome)
            : new CommandInstaller(label, command, toolHome);
    GitTool t = new GitTool("myGit", null, Collections.singletonList(
            new InstallSourceProperty(Collections.singletonList(installer))));
    t.getDescriptor().setInstallations(t);

    GitTool defaultTool = GitTool.getDefaultInstallation();
    GitTool resolved = (GitTool) defaultTool.translate(j.jenkins, new EnvVars(), TaskListener.NULL);
    assertThat(resolved.getGitExe(), containsString(toolHome));
}
 
Example #3
Source File: TerraformTest.java    From configuration-as-code-plugin with MIT License 5 votes vote down vote up
@Test
public void configure_terraform_tool() {
    final TerraformInstallation.DescriptorImpl descriptor = ExtensionList.lookupSingleton(TerraformInstallation.DescriptorImpl.class);
    assertEquals(1, descriptor.getInstallations().length);

    TerraformInstallation terraform = descriptor.getInstallations()[0];
    assertEquals("terraform", terraform.getName());
    assertEquals("/terraform-0.11", terraform.getHome());

    InstallSourceProperty installSourceProperty = terraform.getProperties().get(InstallSourceProperty.class);
    assertEquals(1, installSourceProperty.installers.size());

    TerraformInstaller installer = installSourceProperty.installers.get(TerraformInstaller.class);
    assertEquals("0.11.9-linux-amd64", installer.id);
}
 
Example #4
Source File: SbtTest.java    From configuration-as-code-plugin with MIT License 5 votes vote down vote up
@Test
public void configure_sbt_tool() {
    final SbtPluginBuilder.DescriptorImpl descriptor = ExtensionList.lookupSingleton(SbtPluginBuilder.DescriptorImpl.class);
    assertEquals(1, descriptor.getInstallations().length);

    SbtInstallation sbt = descriptor.getInstallations()[0];
    assertEquals("sbt", sbt.getName());
    assertEquals("/usr/bin/sbt", sbt.getHome());

    InstallSourceProperty installSourceProperty = sbt.getProperties().get(InstallSourceProperty.class);
    assertEquals(1, installSourceProperty.installers.size());

    SbtInstaller installer = installSourceProperty.installers.get(SbtInstaller.class);
    assertEquals("1.2.8", installer.id);
}
 
Example #5
Source File: MercurialTest.java    From configuration-as-code-plugin with MIT License 5 votes vote down vote up
@Test
@ConfiguredWithReadme("mercurial/README.md")
public void should_configure_maven_tools_and_global_config() {
    final Object descriptor = j.jenkins.getDescriptorOrDie(MercurialInstallation.class);
    Assert.assertNotNull(descriptor);
    Assert.assertEquals(1, ((MercurialInstallation.DescriptorImpl) descriptor).getInstallations().length);

    MercurialInstallation mercurial = ((MercurialInstallation.DescriptorImpl) descriptor).getInstallations()[0];
    Assert.assertEquals("Mercurial 3", mercurial.getName());
    Assert.assertEquals("/mercurial", mercurial.getHome());
    Assert.assertEquals("[defaults]\n" +
            "clone = --uncompressed\n" +
            "bundle = --type none", mercurial.getConfig());
    Assert.assertEquals("INSTALLATION/bin/hg", mercurial.getExecutable());
    Assert.assertTrue(mercurial.isUseCaches());
    Assert.assertFalse(mercurial.getDebug());
    Assert.assertFalse(mercurial.getDebug());
    Assert.assertEquals("/cache/root", mercurial.getMasterCacheRoot());
    Assert.assertFalse(mercurial.isUseSharing());

    InstallSourceProperty installSourceProperty = mercurial.getProperties().get(InstallSourceProperty.class);
    Assert.assertEquals(1, installSourceProperty.installers.size());

    CommandInstaller installer = installSourceProperty.installers.get(CommandInstaller.class);
    Assert.assertEquals("mercurial", installer.getToolHome());
    Assert.assertEquals("SomeLabel", installer.getLabel());
    Assert.assertEquals("[ -d mercurial ] || wget -q -O - http://www.archlinux.org/packages/extra/x86_64/mercurial/download/ | xzcat | tar xvf -", installer.getCommand());
}
 
Example #6
Source File: NodeJSTest.java    From configuration-as-code-plugin with MIT License 5 votes vote down vote up
@Test
@ConfiguredWithReadme("nodejs/README.md")
public void configure_nodejs() throws Exception {
    final NodeJSInstallation.DescriptorImpl descriptor = ExtensionList.lookupSingleton(NodeJSInstallation.DescriptorImpl.class);
    assertEquals(1, descriptor.getInstallations().length);

    final NodeJSInstallation nodejs = descriptor.getInstallations()[0];
    final InstallSourceProperty installSourceProperty = nodejs.getProperties().get(InstallSourceProperty.class);
    final NodeJSInstaller nodeJSInstaller = installSourceProperty.installers.get(NodeJSInstaller.class);
    assertEquals("12.11.1", nodeJSInstaller.id);
    assertEquals(48, nodeJSInstaller.getNpmPackagesRefreshHours().longValue());
}
 
Example #7
Source File: CustomToolsTest.java    From configuration-as-code-plugin with MIT License 5 votes vote down vote up
@Test @Issue("#97") @Ignore
@ConfiguredWithCode(value = "CustomToolsTest.yml")
public void configure_custom_tools() throws Exception {
    DescriptorImpl descriptor = (DescriptorImpl) j.jenkins.getDescriptorOrDie(CustomTool.class);
    assertEquals(1, descriptor.getInstallations().length);
    final CustomTool customTool = descriptor.getInstallations()[0];
    final InstallSourceProperty source = customTool.getProperties().get(InstallSourceProperty.class);
    assertNotNull(source);
    final CommandInstaller installer = source.installers.get(CommandInstaller.class);
    assertNotNull(installer);
    assertEquals("/bin/my-tool", installer.getToolHome());
}
 
Example #8
Source File: MavenConfiguratorTest.java    From configuration-as-code-plugin with MIT License 5 votes vote down vote up
@Test
@ConfiguredWithCode("MavenConfiguratorTest.yml")
public void should_configure_maven_tools_and_global_config() {
    final Maven.DescriptorImpl descriptor= (Maven.DescriptorImpl) j.jenkins.getDescriptorOrDie(Maven.class);
    Assert.assertEquals(1, descriptor.getInstallations().length);
    Assert.assertEquals("/usr/share/maven", descriptor.getInstallations()[0].getHome());

    InstallSourceProperty installSourceProperty = descriptor.getInstallations()[0].getProperties().get(InstallSourceProperty.class);
    Assert.assertEquals("3.5.0", installSourceProperty.installers.get(Maven.MavenInstaller.class).id);

    final SettingsProvider provider = GlobalMavenConfig.get().getSettingsProvider();
    Assert.assertTrue(provider instanceof FilePathSettingsProvider);
    Assert.assertEquals("/usr/share/maven-settings.xml", ((FilePathSettingsProvider)provider).getPath());
}
 
Example #9
Source File: GitToolConfiguratorJenkinsRuleTest.java    From git-client-plugin with MIT License 5 votes vote down vote up
@Test
public void testDescribeGitTool() throws Exception {
    String gitName = "git-2.19.1-name";
    String gitHome = "/opt/git-2.19.1/bin/git";

    ConfiguratorRegistry registry = ConfiguratorRegistry.get();
    ConfigurationContext context = new ConfigurationContext(registry);

    List<ToolProperty<ToolInstallation>> gitToolProperties = new ArrayList<>();
    List<ToolInstaller> toolInstallers = new ArrayList<>();
    ToolInstaller toolInstaller = new ZipExtractionInstaller("tool-label", "tool-url", "tool-subdir");
    toolInstallers.add(toolInstaller);
    InstallSourceProperty installSourceProperty = new InstallSourceProperty(toolInstallers);
    gitToolProperties.add(installSourceProperty);

    GitTool gitTool = new GitTool(gitName, gitHome, gitToolProperties);

    CNode cNode = gitToolConfigurator.describe(gitTool, context);

    assertThat(cNode, is(notNullValue()));
    assertThat(cNode.getType(), is(CNode.Type.MAPPING));
    Mapping cNodeMapping = cNode.asMapping();
    assertThat(cNodeMapping.getScalarValue("name"), is(gitName));
    assertThat(cNodeMapping.getScalarValue("home"), is(gitHome));

    //         properties:
    //          - installSource:
    //              installers:
    //                - zip:
    //                    label: "tool-label"
    //                    subdir: "tool-subdir"
    //                    url: "tool-url"
    Sequence propertiesSequence = cNodeMapping.get("properties").asSequence();                             // properties:
    Mapping installSourceMapping = propertiesSequence.get(0).asMapping().get("installSource").asMapping(); //  - installSource:
    Sequence installersSequence = installSourceMapping.get("installers").asSequence();                     //      installers:
    Mapping zipMapping = installersSequence.get(0).asMapping().get("zip").asMapping();                     //        - zip:
    assertThat(zipMapping.getScalarValue("label"), is("tool-label"));
    assertThat(zipMapping.getScalarValue("subdir"), is("tool-subdir"));
    assertThat(zipMapping.getScalarValue("url"), is("tool-url"));
}
 
Example #10
Source File: JcascTest.java    From git-client-plugin with MIT License 4 votes vote down vote up
@Override
protected void assertConfiguredAsExpected(RestartableJenkinsRule restartableJenkinsRule, String s) {
    final ToolDescriptor descriptor = (ToolDescriptor) restartableJenkinsRule.j.jenkins.getDescriptor(GitTool.class);
    final ToolInstallation[] installations = descriptor.getInstallations();
    assertThat(installations, arrayWithSize(4));
    assertThat(installations, arrayContainingInAnyOrder(
            allOf(
                    instanceOf(JGitTool.class),
                    hasProperty("name", equalTo(JGitTool.MAGIC_EXENAME))
            ),
            allOf(
                    instanceOf(JGitApacheTool.class),
                    hasProperty("name", equalTo(JGitApacheTool.MAGIC_EXENAME))
            ),
            allOf(
                    instanceOf(GitTool.class),
                    not(instanceOf(JGitTool.class)),
                    not(instanceOf(JGitApacheTool.class)),
                    hasProperty("name", equalTo("Default")),
                    hasProperty("home", equalTo("git"))
            ),
            allOf(
                    instanceOf(GitTool.class),
                    not(instanceOf(JGitTool.class)),
                    not(instanceOf(JGitApacheTool.class)),
                    hasProperty("name", equalTo("optional")),
                    hasProperty("home", equalTo("/opt/git/git"))
            ))
    );
    final DescribableList<ToolProperty<?>, ToolPropertyDescriptor> properties = Arrays.stream(installations).filter(t -> t.getName().equals("optional")).findFirst().get().getProperties();
    assertThat(properties, iterableWithSize(1));
    final ToolProperty<?> property = properties.get(0);
    assertThat(property, instanceOf(InstallSourceProperty.class));
    assertThat(((InstallSourceProperty)property).installers,
            containsInAnyOrder(
                    allOf(
                            instanceOf(BatchCommandInstaller.class),
                            hasProperty("command", equalTo("echo \"got git\""))
                    ),
                    allOf(
                            instanceOf(ZipExtractionInstaller.class),
                            hasProperty("url", equalTo("file://some/path.zip"))
                    )
            )
    );
}