diff --git a/pkg/container/docker_run.go b/pkg/container/docker_run.go index cc8335dc87e..2747c3001fa 100644 --- a/pkg/container/docker_run.go +++ b/pkg/container/docker_run.go @@ -327,14 +327,20 @@ func (cr *containerReference) create(capAdd []string, capDrop []string) common.E config := &container.Config{ Image: input.Image, - Cmd: input.Cmd, - Entrypoint: input.Entrypoint, WorkingDir: input.WorkingDir, Env: input.Env, Tty: isTerminal, Hostname: input.Hostname, } + if len(input.Cmd) != 0 { + config.Cmd = input.Cmd + } + + if len(input.Entrypoint) != 0 { + config.Entrypoint = input.Entrypoint + } + mounts := make([]mount.Mount, 0) for mountSource, mountTarget := range input.Mounts { mounts = append(mounts, mount.Mount{ diff --git a/pkg/runner/step_docker.go b/pkg/runner/step_docker.go index 5625a155f1b..3a274d0fc8f 100644 --- a/pkg/runner/step_docker.go +++ b/pkg/runner/step_docker.go @@ -58,7 +58,12 @@ func (sd *stepDocker) runUsesContainer() common.Executor { if err != nil { return err } - entrypoint := strings.Fields(eval.Interpolate(step.With["entrypoint"])) + + var entrypoint []string + if entry := eval.Interpolate(step.With["entrypoint"]); entry != "" { + entrypoint = []string{entry} + } + stepContainer := sd.newStepContainer(ctx, image, cmd, entrypoint) return common.NewPipelineExecutor( diff --git a/pkg/runner/testdata/uses-docker-url/push.yml b/pkg/runner/testdata/uses-docker-url/push.yml index 2eee36f5662..336134c59ba 100644 --- a/pkg/runner/testdata/uses-docker-url/push.yml +++ b/pkg/runner/testdata/uses-docker-url/push.yml @@ -9,3 +9,15 @@ jobs: with: somekey: somevalue args: echo ${INPUT_SOMEKEY} | grep somevalue + - uses: docker://node:16-buster-slim + with: + args: -v + - uses: docker://node:16-buster-slim + with: + entrypoint: /bin/sh + args: -c -- uname -a + - uses: docker://node:16-buster-slim + with: + entrypoint: /bin/sh + args: -c 'uname -a' +