diff --git a/src/main/java/com/bioraft/rundeck/rancher/Constants.java b/src/main/java/com/bioraft/rundeck/rancher/Constants.java index e20c5b0..0700c52 100644 --- a/src/main/java/com/bioraft/rundeck/rancher/Constants.java +++ b/src/main/java/com/bioraft/rundeck/rancher/Constants.java @@ -35,7 +35,7 @@ private Constants() { public static final int INTERVAL_MILLIS = 2000; @SuppressWarnings("SpellCheckingInspection") - public static final String STDERR_TOKEN = ";v9ZvwThpU1FtyrlIBf4UIC8"; + public static final String STDERR_TOKEN = ":v9ZvwThpU1FtyrlIBf4UIC8:"; // These are fields in JSON from Rancher API. public static final String NODE_ID = "id"; diff --git a/src/main/java/com/bioraft/rundeck/rancher/IResolverUtil.java b/src/main/java/com/bioraft/rundeck/rancher/IResolverUtil.java index 1a17030..5a0b189 100644 --- a/src/main/java/com/bioraft/rundeck/rancher/IResolverUtil.java +++ b/src/main/java/com/bioraft/rundeck/rancher/IResolverUtil.java @@ -65,6 +65,7 @@ public static int resolveIntProperty( try { value = Integer.parseInt(string); } catch (NumberFormatException e) { + return defaultValue; } } return value; @@ -85,6 +86,7 @@ public static long resolveLongProperty( try { value = Long.parseLong(string); } catch (NumberFormatException e) { + return defaultValue; } } return value; diff --git a/src/main/java/com/bioraft/rundeck/rancher/RancherFileCopier.java b/src/main/java/com/bioraft/rundeck/rancher/RancherFileCopier.java index 708a3fb..c9ac02a 100644 --- a/src/main/java/com/bioraft/rundeck/rancher/RancherFileCopier.java +++ b/src/main/java/com/bioraft/rundeck/rancher/RancherFileCopier.java @@ -25,7 +25,6 @@ package com.bioraft.rundeck.rancher; import com.dtolabs.rundeck.core.Constants; -import com.dtolabs.rundeck.core.common.Framework; import com.dtolabs.rundeck.core.common.IFramework; import com.dtolabs.rundeck.core.common.INodeEntry; import com.dtolabs.rundeck.core.common.IRundeckProject; diff --git a/src/main/java/com/bioraft/rundeck/rancher/RancherWebSocketListener.java b/src/main/java/com/bioraft/rundeck/rancher/RancherWebSocketListener.java index bf33173..5722c35 100644 --- a/src/main/java/com/bioraft/rundeck/rancher/RancherWebSocketListener.java +++ b/src/main/java/com/bioraft/rundeck/rancher/RancherWebSocketListener.java @@ -123,10 +123,10 @@ public static void runJob(String url, String accessKey, String secretKey, String private static String[] remoteCommand(String[] command, String temp) { String file = temp + ".pid; "; // Prefix STDERR lines with STDERR_TOKEN to decode in logging step. - String cmd = String.join(" ", command); - String job = "( " + cmd + " ) 2> >(sed 's/^/" + STDERR_TOKEN + "/')"; + String cmd = "( " + String.join(" ", command) + " )"; + String sed = " 2> >(while IFS= read -r line || [ -n \"$line\" ]; do echo " + STDERR_TOKEN + "$line ; done)"; // Note that bash is required to support adding a prefix token to STDERR. - return new String[]{ "bash", "-c", "printf $$ >>" + file + job + ";printf ' %s' $? >>" + file }; + return new String[]{ "bash", "-c", "printf $$ >>" + file + cmd + sed + ";printf ' %s' $? >>" + file }; } @Override diff --git a/src/main/java/com/bioraft/rundeck/rancher/Storage.java b/src/main/java/com/bioraft/rundeck/rancher/Storage.java index 829b768..bcccb98 100644 --- a/src/main/java/com/bioraft/rundeck/rancher/Storage.java +++ b/src/main/java/com/bioraft/rundeck/rancher/Storage.java @@ -38,7 +38,7 @@ public String loadStoragePathData(final String passwordStoragePath) throws IOExc ResourceMeta contents = executionContext.getStorageTree().getResource(passwordStoragePath).getContents(); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); contents.writeContent(byteArrayOutputStream); - return new String(byteArrayOutputStream.toByteArray()); + return byteArrayOutputStream.toString(); } }