ImageAction.add(step.image, run); getContext().newBodyInvoker(). withContext(BodyInvoker.mergeLauncherDecorators(getContext().get(LauncherDecorator.class), new Decorator(container, envHost, ws, toolName, dockerVersion))). withCallback(new Callback(container, toolName)). start();
@Override public boolean start() throws Exception { StepContext context = getContext(); if (obj instanceof ConsoleLogFilter) { obj = BodyInvoker.mergeConsoleLogFilters(context.get(ConsoleLogFilter.class), (ConsoleLogFilter) obj); } else if (obj instanceof LauncherDecorator) { obj = BodyInvoker.mergeLauncherDecorators(context.get(LauncherDecorator.class), (LauncherDecorator) obj); } else if (obj instanceof EnvironmentExpander) { obj = EnvironmentExpander.merge(context.get(EnvironmentExpander.class), (EnvironmentExpander) obj); } context.newBodyInvoker().withContext(obj).withCallback(BodyExecutionCallback.wrap(context)).start(); return false; }
@Override public boolean start() throws Exception { StepContext context = getContext(); podName = step.getName() + "-" + UUID.randomUUID().toString(); final AtomicBoolean podAlive = new AtomicBoolean(false); final CountDownLatch podStarted = new CountDownLatch(1); final CountDownLatch podFinished = new CountDownLatch(1); //The body is executed async. so we can't use try with resource here. final KubernetesFacade kubernetes = new KubernetesFacade(); PodTemplate newTemplate = new PodTemplate(); newTemplate.setName(podName); newTemplate.setLabel(step.getName()); newTemplate.setVolumes(step.getVolumes()); newTemplate.setContainers(step.getContainers()); newTemplate.setNodeSelector(step.getNodeSelector()); newTemplate.setServiceAccount(step.getServiceAccount()); //Get host using env vars and fallback to computer name (integration point with kubernetes-plugin). String hostname = env.get(Constants.HOSTNAME, computer.getName()); String jobname = env.get(Constants.JOB_NAME, computer.getName()); kubernetes.createPod(hostname, jobname, newTemplate, workspace.getRemote(), step.getLabels()); kubernetes.watch(podName, podAlive, podStarted, podFinished, true); podStarted.await(); String containerName = step.getContainers().get(step.getContainers().size() - 1).getName(); context.newBodyInvoker() .withContext(BodyInvoker .mergeLauncherDecorators(getContext().get(LauncherDecorator.class), new PodExecDecorator(kubernetes, podName, containerName, podAlive, podStarted, podFinished))) .withCallback(new PodCallback(podName)) .start(); return false; }
getContext().newBodyInvoker() .withContext(BodyInvoker .mergeLauncherDecorators(getContext().get(LauncherDecorator.class), decorator)) .withCallback(new ContainerExecCallback(decorator)) .start();