Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add new line when logging the agent in jenkins #267

Merged
merged 1 commit into from
Dec 14, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import org.kohsuke.stapler.DataBoundConstructor;

import java.io.IOException;
import java.io.PrintStream;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collection;
Expand Down Expand Up @@ -112,6 +113,8 @@ public boolean isLaunchSupported() {

@Override
public void launch(SlaveComputer computer, TaskListener listener) {
PrintStream logger = listener.getLogger();

if (!(computer instanceof KubernetesComputer)) {
throw new IllegalArgumentException("This Launcher can be used only with KubernetesComputer");
}
Expand Down Expand Up @@ -139,7 +142,7 @@ public void launch(SlaveComputer computer, TaskListener listener) {
LOGGER.log(Level.FINE, "Creating Pod: {0} in namespace {1}", new Object[]{podId, namespace});
pod = client.pods().inNamespace(namespace).create(pod);
LOGGER.log(INFO, "Created Pod: {0} in namespace {1}", new Object[]{podId, namespace});
listener.getLogger().printf("Created Pod: %s in namespace %s", podId, namespace);
logger.printf("Created Pod: %s in namespace %s%n", podId, namespace);

// We need the pod to be running and connected before returning
// otherwise this method keeps being called multiple times
Expand All @@ -153,7 +156,7 @@ public void launch(SlaveComputer computer, TaskListener listener) {
// wait for Pod to be running
for (; i < j; i++) {
LOGGER.log(INFO, "Waiting for Pod to be scheduled ({1}/{2}): {0}", new Object[]{podId, i, j});
listener.getLogger().printf("Waiting for Pod to be scheduled (%2$s/%3$s): %1$s", podId, i, j);
logger.printf("Waiting for Pod to be scheduled (%2$s/%3$s): %1$s%n", podId, i, j);

Thread.sleep(6000);
pod = client.pods().inNamespace(namespace).withName(podId).get();
Expand All @@ -170,7 +173,7 @@ public void launch(SlaveComputer computer, TaskListener listener) {
// Pod is waiting for some reason
LOGGER.log(INFO, "Container is waiting {0} [{2}]: {1}",
new Object[]{podId, info.getState().getWaiting(), info.getName()});
listener.getLogger().printf("Container is waiting %1$s [%3$s]: %2$s",
logger.printf("Container is waiting %1$s [%3$s]: %2$s%n",
podId, info.getState().getWaiting(), info.getName());
// break;
}
Expand Down Expand Up @@ -215,7 +218,7 @@ public void launch(SlaveComputer computer, TaskListener listener) {
break;
}
LOGGER.log(INFO, "Waiting for slave to connect ({1}/{2}): {0}", new Object[]{podId, i, j});
listener.getLogger().printf("Waiting for slave to connect (%2$s/%3$s): %1$s", podId, i, j);
logger.printf("Waiting for slave to connect (%2$s/%3$s): %1$s%n", podId, i, j);
Thread.sleep(1000);
}
if (!slave.getComputer().isOnline()) {
Expand Down