hudson.tools.ToolProperty Java Examples
The following examples show how to use
hudson.tools.ToolProperty.
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: DockerDSLTest.java From docker-workflow-plugin with MIT License | 6 votes |
@Test public void withTool() { story.addStep(new Statement() { @Override public void evaluate() throws Throwable { assumeDocker(); assumeTrue(new File("/usr/bin/docker").canExecute()); // TODO generalize to find docker in $PATH story.j.jenkins.getDescriptorByType(DockerTool.DescriptorImpl.class).setInstallations(new DockerTool("default", "/usr", Collections.<ToolProperty<?>>emptyList())); WorkflowJob p = story.j.jenkins.createProject(WorkflowJob.class, "prj"); p.setDefinition(new CpsFlowDefinition( "docker.withTool('default') {\n" + " docker.image('httpd:2.4.12').withRun {}\n" + " sh 'echo PATH=$PATH'\n" + "}", true)); story.j.assertLogContains("PATH=/usr/bin:", story.j.assertBuildStatusSuccess(p.scheduleBuild2(0))); } }); }
Example #2
Source File: GitToolConfiguratorJenkinsRuleTest.java From git-client-plugin with MIT License | 6 votes |
@Test public void testDescribeGitToolEmptyProperties() 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); // Intentionally empty properties passed to GitTool constructor List<ToolProperty<ToolInstallation>> gitToolProperties = new ArrayList<>(); 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)); }
Example #3
Source File: GitToolConfigurator.java From git-client-plugin with MIT License | 6 votes |
@CheckForNull @Override public CNode describe(GitTool instance, ConfigurationContext context) throws Exception { Mapping mapping = new Mapping(); if (instance instanceof JGitTool) { mapping.put("name", JGitTool.MAGIC_EXENAME); } else if (instance instanceof JGitApacheTool) { mapping.put("name", JGitApacheTool.MAGIC_EXENAME); } else if (instance != null) { mapping.put("name", instance.getName()); mapping.put("home", instance.getHome()); } if (context != null && instance != null && instance.getProperties() != null && !instance.getProperties().isEmpty()) { final Configurator<ToolProperty> configurator = context.lookupOrFail(ToolProperty.class); Sequence s = new Sequence(instance.getProperties().size()); for (ToolProperty<?> property : instance.getProperties()) { s.add(configurator.describe(property, context)); } mapping.put("properties", s); } return mapping; }
Example #4
Source File: GitTool.java From git-client-plugin with MIT License | 6 votes |
@Initializer(after=EXTENSIONS_AUGMENTED) public static void onLoaded() { //Creates default tool installation if needed. Uses "git" or migrates data from previous versions Jenkins jenkinsInstance = Jenkins.getInstance(); DescriptorImpl descriptor = (DescriptorImpl) jenkinsInstance.getDescriptor(GitTool.class); GitTool[] installations = getInstallations(descriptor); if (installations != null && installations.length > 0) { //No need to initialize if there's already something return; } String defaultGitExe = isWindows() ? "git.exe" : "git"; GitTool tool = new GitTool(DEFAULT, defaultGitExe, Collections.<ToolProperty<?>>emptyList()); descriptor.setInstallations(new GitTool[] { tool }); descriptor.save(); }
Example #5
Source File: GitToolConfigurator.java From git-client-plugin with MIT License | 6 votes |
@NonNull private List<ToolProperty<?>> instantiateProperties(@CheckForNull CNode props, @NonNull ConfigurationContext context) throws ConfiguratorException { List<ToolProperty<?>> toolProperties = new ArrayList<>(); if (props == null) { return toolProperties; } final Configurator<ToolProperty> configurator = context.lookupOrFail(ToolProperty.class); if (props instanceof Sequence) { Sequence s = (Sequence) props; for (CNode cNode : s) { toolProperties.add(configurator.configure(cNode, context)); } } else { toolProperties.add(configurator.configure(props, context)); } return toolProperties; }
Example #6
Source File: WithContainerStepTest.java From docker-workflow-plugin with MIT License | 5 votes |
@Test public void configRoundTrip() { story.addStep(new Statement() { @Override public void evaluate() throws Throwable { WithContainerStep s1 = new WithContainerStep("java"); s1.setArgs("--link db:db"); story.j.assertEqualDataBoundBeans(s1, new StepConfigTester(story.j).configRoundTrip(s1)); story.j.jenkins.getDescriptorByType(DockerTool.DescriptorImpl.class).setInstallations(new DockerTool("docker15", "/usr/local/docker15", Collections.<ToolProperty<?>>emptyList())); s1.setToolName("docker15"); story.j.assertEqualDataBoundBeans(s1, new StepConfigTester(story.j).configRoundTrip(s1)); } }); }
Example #7
Source File: GitToolConfiguratorTest.java From git-client-plugin with MIT License | 5 votes |
@Test public void testGetAttributes() { List<Attribute<GitTool, ?>> gitToolAttributes = gitToolConfigurator.getAttributes(); Attribute<GitTool, String> name = new Attribute<>("name", String.class); Attribute<GitTool, String> home = new Attribute<>("home", String.class); Attribute<GitTool, ToolProperty> p = new Attribute<>("properties", ToolProperty.class); assertThat(gitToolAttributes, containsInAnyOrder(name, home, p)); }
Example #8
Source File: GitToolConfiguratorJenkinsRuleTest.java From git-client-plugin with MIT License | 5 votes |
@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 #9
Source File: DockerToolTest.java From docker-commons-plugin with MIT License | 5 votes |
@Test public void getExecutable() throws Exception { assertEquals(DockerTool.COMMAND, DockerTool.getExecutable(null, null, null, null)); DockerTool.DescriptorImpl descriptor = r.jenkins.getDescriptorByType(DockerTool.DescriptorImpl.class); String name = "docker15"; descriptor.setInstallations(new DockerTool(name, "/usr/local/docker15", Collections.<ToolProperty<?>>emptyList())); // TODO r.jenkins.restart() does not reproduce need for get/setInstallations; use RestartableJenkinsRule in 1.567+ assertEquals("/usr/local/docker15/bin/docker", DockerTool.getExecutable(name, null, null, null)); DumbSlave slave = r.createOnlineSlave(); slave.getNodeProperties().add(new ToolLocationNodeProperty(new ToolLocationNodeProperty.ToolLocation(descriptor, name, "/opt/docker"))); assertEquals("/usr/local/docker15/bin/docker", DockerTool.getExecutable(name, null, null, null)); assertEquals("/opt/docker/bin/docker", DockerTool.getExecutable(name, slave, StreamTaskListener.fromStderr(), null)); }
Example #10
Source File: ConfigTest.java From docker-commons-plugin with MIT License | 5 votes |
@Test public void configRoundTrip() throws Exception { CredentialsStore store = CredentialsProvider.lookupStores(r.jenkins).iterator().next(); IdCredentials serverCredentials = new DockerServerCredentials(CredentialsScope.GLOBAL, "serverCreds", null, Secret.fromString("clientKey"), "clientCertificate", "serverCaCertificate"); store.addCredentials(Domain.global(), serverCredentials); IdCredentials registryCredentials = new UsernamePasswordCredentialsImpl(CredentialsScope.GLOBAL, "registryCreds", null, "me", "pass"); store.addCredentials(Domain.global(), registryCredentials); SampleDockerBuilder b1 = new SampleDockerBuilder(new DockerServerEndpoint("", ""), new DockerRegistryEndpoint("http://dhe.mycorp.com/", registryCredentials.getId())); r.assertEqualDataBoundBeans(b1, r.configRoundtrip(b1)); b1 = new SampleDockerBuilder(new DockerServerEndpoint("tcp://192.168.1.104:8333", serverCredentials.getId()), new DockerRegistryEndpoint("", "")); r.assertEqualDataBoundBeans(b1, r.configRoundtrip(b1)); r.jenkins.getDescriptorByType(DockerTool.DescriptorImpl.class).setInstallations(new DockerTool("Docker 1.5", "/usr/local/docker15", Collections.<ToolProperty<?>>emptyList())); b1.setToolName("Docker 1.5"); r.assertEqualDataBoundBeans(b1, r.configRoundtrip(b1)); }
Example #11
Source File: PackerInstallation.java From packer-plugin with MIT License | 5 votes |
@DataBoundConstructor public PackerInstallation(String name, String home, String params, JSONObject templateMode, List<PackerFileEntry> fileEntries, List<? extends ToolProperty<?>> properties) { this(name, launderHome(home), params, templateMode.optString("jsonTemplate", null), templateMode.optString("jsonTemplateText", null), Strings.isNullOrEmpty(templateMode.optString("value", null)) ? TemplateMode.TEXT.toMode() : templateMode.getString("value"), fileEntries, properties); }
Example #12
Source File: PackerInstallation.java From packer-plugin with MIT License | 5 votes |
private PackerInstallation(String name, String home, String params, String jsonTemplate, String jsonTemplateText, String templateMode, List<PackerFileEntry> fileEntries, List<? extends ToolProperty<?>> properties) { super(name, home, properties); this.packerHome = super.getHome(); this.params = params; this.fileEntries = fileEntries; this.jsonTemplate = jsonTemplate; this.jsonTemplateText = jsonTemplateText; this.templateMode = templateMode; }
Example #13
Source File: GitToolConfigurator.java From git-client-plugin with MIT License | 5 votes |
@NonNull @Override public List<Attribute<GitTool, ?>> getAttributes() { Attribute<GitTool, String> name = new Attribute<>("name", String.class); Attribute<GitTool, String> home = new Attribute<>("home", String.class); Attribute<GitTool, ToolProperty> p = new Attribute<>("properties", ToolProperty.class); p.multiple(true); return Arrays.asList(name, home, p); }
Example #14
Source File: GitTool.java From git-client-plugin with MIT License | 4 votes |
public GitTool forEnvironment(EnvVars environment) { return new GitTool(getName(), environment.expand(getHome()), Collections.<ToolProperty<?>>emptyList()); }
Example #15
Source File: JcascTest.java From git-client-plugin with MIT License | 4 votes |
@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")) ) ) ); }
Example #16
Source File: JGitTool.java From git-client-plugin with MIT License | 4 votes |
/** * Constructor for JGitTool. */ public JGitTool() { this(Collections.<ToolProperty<?>>emptyList()); }
Example #17
Source File: JGitApacheTool.java From git-client-plugin with MIT License | 4 votes |
public JGitApacheTool() { this(Collections.<ToolProperty<?>>emptyList()); }
Example #18
Source File: JGitApacheTool.java From git-client-plugin with MIT License | 4 votes |
@DataBoundConstructor public JGitApacheTool(final List<? extends ToolProperty<?>> properties) { super(MAGIC_EXENAME, MAGIC_EXENAME, properties); }
Example #19
Source File: OpenShiftClientTools.java From jenkins-client-plugin with Apache License 2.0 | 4 votes |
@DataBoundConstructor public OpenShiftClientTools(String name, String home, List<? extends ToolProperty<?>> properties) { super(name, home, properties); }
Example #20
Source File: GitTool.java From git-client-plugin with MIT License | 4 votes |
public GitTool forNode(Node node, TaskListener log) throws IOException, InterruptedException { return new GitTool(getName(), translateFor(node, log), Collections.<ToolProperty<?>>emptyList()); }
Example #21
Source File: DockerTool.java From docker-commons-plugin with MIT License | 4 votes |
@DataBoundConstructor public DockerTool(String name, String home, List<? extends ToolProperty<?>> properties) { super(name, home, properties); }
Example #22
Source File: AnsibleInstallation.java From ansible-plugin with Apache License 2.0 | 4 votes |
@DataBoundConstructor public AnsibleInstallation(String name, String home, List<? extends ToolProperty<?>> properties) { super(name, home, properties); }
Example #23
Source File: OpenShiftClientTools.java From jenkins-client-plugin with Apache License 2.0 | 4 votes |
@DataBoundConstructor public OpenShiftClientTools(String name, String home, List<? extends ToolProperty<?>> properties) { super(name, home, properties); }
Example #24
Source File: JGitTool.java From git-client-plugin with MIT License | 2 votes |
/** * Constructor for JGitTool. * * @param properties a {@link java.util.List} object. */ @DataBoundConstructor public JGitTool(List<? extends ToolProperty<?>> properties) { super("jgit", MAGIC_EXENAME, properties); }
Example #25
Source File: GitTool.java From git-client-plugin with MIT License | 2 votes |
/** * Constructor for GitTool. * * @param name Tool name (for example, "git" or "jgit") * @param home Tool location (usually "git") * @param properties {@link java.util.List} of properties for this tool */ @DataBoundConstructor public GitTool(String name, String home, List<? extends ToolProperty<?>> properties) { super(name, home, properties); }