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

Verifying that tools do not assume sh is in /bin/sh #490

Merged
merged 10 commits into from
Jul 6, 2019
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@
<version>6.7</version>
</dependency>

<dependency> <!-- OnceRetentionStrategy -->
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>durable-task</artifactId>
<version>1.28</version>
<version>1.30-SNAPSHOT</version> <!-- TODO https://github.com/jenkinsci/durable-task-plugin/pull/95 -->
jglick marked this conversation as resolved.
Show resolved Hide resolved
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public class ContainerExecDecorator extends LauncherDecorator implements Seriali
private static final String COOKIE_VAR = "JENKINS_SERVER_COOKIE";

private static final Logger LOGGER = Logger.getLogger(ContainerExecDecorator.class.getName());
private static final String DEFAULT_SHELL="/bin/sh";
private static final String DEFAULT_SHELL = "sh";

/**
* stdin buffer size for commands sent to Kubernetes exec api. A low value will cause slowness in commands executed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,12 @@ public void runInPodWithDifferentShell() throws Exception {
r.assertLogContains("/bin/bash: no such file or directory", b);
}

@Test
public void bourneShellElsewhereInPath() throws Exception {
r.assertBuildStatusSuccess(r.waitForCompletion(b));
r.assertLogContains("+ ls -la /", b);
}

@Test
public void runInPodWithMultipleContainers() throws Exception {
r.assertBuildStatusSuccess(r.waitForCompletion(b));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
podTemplate(label: 'bourneShellElsewhereInPath', containers: [containerTemplate(name: 'kaniko', image: 'gcr.io/kaniko-project/executor:debug', command: 'sleep', args: '99d')]) {
node('bourneShellElsewhereInPath') {
container(name: 'kaniko') {
Copy link
Member Author

@jglick jglick Jun 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without the ContainerExecDecorator patch, this fails unless you

-container(name: 'kaniko') {
+container(name: 'kaniko', shell: '/busybox/sh') {

sh 'ls -la /'
Copy link
Member Author

@jglick jglick Jun 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without the BourneShellScript patch, this fails unless you

-sh 'ls -la /'
+sh '''#!/busybox/sh -ex
+    ls -la /
+'''

}
}
}