Skip to content

Commit

Permalink
fix vars, use user for launch script (KostyaSha#211)
Browse files Browse the repository at this point in the history
* fix vars, use user for launch script

* change logic
  • Loading branch information
KostyaSha authored Nov 1, 2017
1 parent ad326c0 commit db0026e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,8 @@ public void appendContainerConfig(DockerSlaveTemplate dockerSlaveTemplate, Creat
"-cxe",
"cat << EOF >> /tmp/init.sh && chmod +x /tmp/init.sh && exec /tmp/init.sh\n" +
initCmd.replace("$", "\\$") + "\n" +
"EOF" + "\n"
);
"EOF" + "\n")
.withUser("root");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ public void appendContainerConfig(CreateContainerCmd createContainerCmd)

createContainerCmd.withTty(true);
createContainerCmd.withStdinOpen(true);
createContainerCmd.withUser("root");
}

private void printLog(DockerClient client, TaskListener listener, String containerId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ public void perform(@Nonnull Run<?, ?> run, @Nonnull FilePath workspace, @Nonnul
insertLabels(containerConfig, run);

if (nonNull(executorScript)) {
containerConfig.withUser("root");
containerConfig.withEntrypoint("/bin/sh", "/tmp/executor.sh");
containerConfig.withCmd("");
}
Expand Down Expand Up @@ -268,8 +269,10 @@ protected static void addRunVars(Run run, TaskListener listener,
CreateContainerCmd containerConfig) {
// add job vars into shell env vars
try {
final List<String> envList = isNull(containerConfig.getEnv()) ?
new ArrayList<>() : Arrays.asList(containerConfig.getEnv());
final List<String> envList = new ArrayList<>();
if (nonNull(containerConfig.getEnv())) {
envList.addAll(Arrays.asList(containerConfig.getEnv()));
}

final EnvVars environment = getEnvVars(run, listener);
// maybe something should be escaped
Expand Down

0 comments on commit db0026e

Please sign in to comment.