Search in sources :

Example 6 with ContainerTemplate

use of org.csanchez.jenkins.plugins.kubernetes.ContainerTemplate in project kubernetes-plugin by jenkinsci.

the class RestartPipelineTest method nullLabelSupportsRestart.

@Test
public void nullLabelSupportsRestart() {
    AtomicReference<String> projectName = new AtomicReference<>();
    story.then(r -> {
        configureAgentListener();
        configureCloud();
        PodTemplate pt = new PodTemplate();
        pt.setName("test");
        pt.setNodeUsageMode(Node.Mode.NORMAL);
        ContainerTemplate ct = new ContainerTemplate("busybox", "busybox");
        ct.setTtyEnabled(true);
        ct.setCommand("/bin/cat");
        pt.setContainers(Collections.singletonList(ct));
        cloud.setTemplates(Collections.singletonList(pt));
        r.jenkins.setNumExecutors(0);
        WorkflowRun b = getPipelineJobThenScheduleRun(r);
        projectName.set(b.getParent().getFullName());
        r.waitForMessage("+ sleep 5", b);
    });
    story.then(r -> {
        WorkflowRun b = r.jenkins.getItemByFullName(projectName.get(), WorkflowJob.class).getBuildByNumber(1);
        r.waitForMessage("Ready to run", b);
        r.assertLogContains("finished the test!", r.assertBuildStatusSuccess(r.waitForCompletion(b)));
    });
}
Also used : ContainerTemplate(org.csanchez.jenkins.plugins.kubernetes.ContainerTemplate) AtomicReference(java.util.concurrent.atomic.AtomicReference) WorkflowJob(org.jenkinsci.plugins.workflow.job.WorkflowJob) WorkflowRun(org.jenkinsci.plugins.workflow.job.WorkflowRun) PodTemplate(org.csanchez.jenkins.plugins.kubernetes.PodTemplate) Test(org.junit.Test)

Aggregations

ContainerTemplate (org.csanchez.jenkins.plugins.kubernetes.ContainerTemplate)6 PodTemplate (org.csanchez.jenkins.plugins.kubernetes.PodTemplate)6 KubernetesCloud (org.csanchez.jenkins.plugins.kubernetes.KubernetesCloud)2 Test (org.junit.Test)2 AbortException (hudson.AbortException)1 TaskListener (hudson.model.TaskListener)1 Pod (io.fabric8.kubernetes.api.model.Pod)1 PodList (io.fabric8.kubernetes.api.model.PodList)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 ContainerLivenessProbe (org.csanchez.jenkins.plugins.kubernetes.ContainerLivenessProbe)1 KubernetesSlave (org.csanchez.jenkins.plugins.kubernetes.KubernetesSlave)1 PodAnnotation (org.csanchez.jenkins.plugins.kubernetes.PodAnnotation)1 PodImagePullSecret (org.csanchez.jenkins.plugins.kubernetes.PodImagePullSecret)1 Merge (org.csanchez.jenkins.plugins.kubernetes.pod.yaml.Merge)1 Overrides (org.csanchez.jenkins.plugins.kubernetes.pod.yaml.Overrides)1 DynamicPVCWorkspaceVolume (org.csanchez.jenkins.plugins.kubernetes.volumes.workspace.DynamicPVCWorkspaceVolume)1 WorkspaceVolume (org.csanchez.jenkins.plugins.kubernetes.volumes.workspace.WorkspaceVolume)1 WorkflowJob (org.jenkinsci.plugins.workflow.job.WorkflowJob)1 WorkflowRun (org.jenkinsci.plugins.workflow.job.WorkflowRun)1 BodyInvoker (org.jenkinsci.plugins.workflow.steps.BodyInvoker)1