Java Code Examples for jenkins.model.Jenkins#CloudList
The following examples show how to use
jenkins.model.Jenkins#CloudList .
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: ECSTaskTemplateStepExecution.java From amazon-ecs-plugin with MIT License | 6 votes |
private Cloud findCloud(String parentLabel) { Cloud cloud = null; Jenkins.CloudList clouds = cloudSupplier.get(); if (parentLabel != null) { for (Cloud c: clouds) { if (c instanceof ECSCloud) { ECSCloud ecsCloud = (ECSCloud)c; if (ecsCloud.canProvision(parentLabel)){ cloud = c; break; } } } } else { cloud = clouds.getByName(this.cloudName); } return cloud; }
Example 2
Source File: ECSTaskTemplateStep.java From amazon-ecs-plugin with MIT License | 4 votes |
@Override public StepExecution start(StepContext stepContext) throws Exception { LOGGER.log(Level.FINE, "In ECSTaskTemplateStep start. label: {0}", label); LOGGER.log(Level.FINE, "In ECSTaskTemplateStep start. cloud: {0}", cloud); return new ECSTaskTemplateStepExecution(this, stepContext, (SerializableSupplier<Jenkins.CloudList>)() -> Jenkins.get().clouds); }
Example 3
Source File: ECSTaskTemplateStepExecution.java From amazon-ecs-plugin with MIT License | 4 votes |
ECSTaskTemplateStepExecution(ECSTaskTemplateStep ecsTaskTemplateStep, StepContext context, SerializableSupplier<Jenkins.CloudList> cloudSupplier ) { super(context); this.step = ecsTaskTemplateStep; this.cloudName = ecsTaskTemplateStep.getCloud(); this.cloudSupplier = cloudSupplier; }
Example 4
Source File: ECSTaskTemplateStepExecutionTest.java From amazon-ecs-plugin with MIT License | 4 votes |
@Test public void testMerge() throws Exception { StepContext context = mock(StepContext.class); BodyInvoker invoker = mock(BodyInvoker.class); when(context.newBodyInvoker()).thenReturn(invoker); when(invoker.withCallback(any(BodyExecutionCallback.TailCall.class))).thenReturn(invoker); ECSCloud cloud = mock(ECSCloud.class); when(cloud.getDisplayName()).thenReturn("my-cloud"); when(cloud.isAllowedOverride("image")).thenReturn(true); when(cloud.isAllowedOverride("taskRole")).thenReturn(true); ECSTaskTemplate parentTemplate = getTaskTemplate("parent-name", "parent-label"); when(cloud.findParentTemplate(parentTemplate.getLabel())).thenReturn(parentTemplate); when(cloud.canProvision(parentTemplate.getLabel())).thenReturn(true); step = new ECSTaskTemplateStep("child-label", "child-name"); step.setInheritFrom(parentTemplate.getLabel()); Jenkins.CloudList clouds = new Jenkins.CloudList(); clouds.add(cloud); step.setOverrides(Arrays.asList("image","taskRole")); ECSTaskTemplateStepExecution executionStep = new ECSTaskTemplateStepExecution(step, context, (SerializableSupplier<Jenkins.CloudList>) () -> clouds); Random r = new Random(); ECSTaskTemplate expected = new ECSTaskTemplate( "template-name", "child-label", UUID.randomUUID().toString(), null, "image-override", UUID.randomUUID().toString(), UUID.randomUUID().toString(), UUID.randomUUID().toString(), UUID.randomUUID().toString(), false, null, r.nextInt(123), r.nextInt(456), r.nextInt(1024), UUID.randomUUID().toString(), UUID.randomUUID().toString(), r.nextBoolean(), r.nextBoolean(), UUID.randomUUID().toString(), null, null, null, null, null, UUID.randomUUID().toString(), null, "override-task-role", null, r.nextInt(123)); // Overriding the entrypoint is inconsistent... why? You can't do it in the step // expected.setEntrypoint("entrypoint-override"); step.setInheritFrom(parentTemplate.getLabel()); step.setLogDriver(expected.getLogDriver()); step.setImage(expected.getImage()); step.setLaunchType(expected.getLaunchType()); step.setTaskDefinitionOverride(expected.getTaskDefinitionOverride()); step.setRepositoryCredentials(expected.getRepositoryCredentials()); step.setNetworkMode(expected.getNetworkMode()); step.setRemoteFSRoot(expected.getRemoteFSRoot()); step.setUniqueRemoteFSRoot(expected.getUniqueRemoteFSRoot()); step.setPlatformVersion(expected.getPlatformVersion()); step.setMemory(expected.getMemory()); step.setMemoryReservation(expected.getMemoryReservation()); step.setCpu(expected.getCpu()); step.setSubnets(expected.getSubnets()); step.setSecurityGroups(expected.getSecurityGroups()); step.setAssignPublicIp(expected.getAssignPublicIp()); step.setPrivileged(expected.getPrivileged()); step.setContainerUser(expected.getContainerUser()); step.setLogDriverOptions(expected.getLogDriverOptions()); step.setEnvironments(expected.getEnvironments()); step.setExtraHosts(expected.getExtraHosts()); step.setMountPoints(expected.getMountPoints()); step.setPortMappings(expected.getPortMappings()); step.setExecutionRole(expected.getExecutionRole()); step.setPlacementStrategies(expected.getPlacementStrategies()); step.setTaskrole(expected.getTaskrole()); step.setSharedMemorySize(expected.getSharedMemorySize()); when(invoker.withContext(step)).thenReturn(invoker); executionStep.start(); verify(cloud,times(1)).addDynamicTemplate(expected); }