buildkite-plugins / docker-buildkite-plugin

🐳📦 Run any build step in a Docker container
MIT License
113 stars 106 forks source link

Unfurl command for docker run #120

Closed pecigonzalo closed 5 years ago

pecigonzalo commented 5 years ago

Commands passed to docker run should be unfurled, otherwise they do not work as intended, for example the node snipped from the readme:

  - command:
      - "yarn install"
      - "yarn run test"
    plugins:
      - docker#v3.1.0:
          image: "node:7"
          always-pull: true
          environment:
            - "MY_SECRET_KEY"
            - "MY_SPECIAL_BUT_PUBLIC_VALUE=kittens"

would output:

yarn run test' in node:7
--
  | docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"yarn install\\nyarn run test\": executable file not found in $PATH": unknown.
  | 🚨 Error: The command exited with status 127

This is because its like doing: docker run --rm node:7 "yarn install" instead of docker run --rm node:7 yarn install

Line: https://github.com/buildkite-plugins/docker-buildkite-plugin/blob/7c8e01ee90ebc29bb23436a52d924ecf1a2c43fa/hooks/command#L363

should probably change to

[...] docker run ${args[@]}
lox commented 5 years ago

That's really odd, that is supposed to work 🤔 Let me test this.

For some context, check out "Improved Shell Handling" in https://github.com/buildkite-plugins/docker-buildkite-plugin/releases/tag/v2.0.0 for how it's supposed to work.

lox commented 5 years ago

This seems to work ok for me. It should be executing:

/bin/sh -e -c 'yarn install
yarn run test'

Which is totally correct.

lox commented 5 years ago

I'll close this one for now, let me know if I've misunderstood!

pecigonzalo commented 5 years ago

Yep, that output would be totally correct. I wonder if this was an error of the node image, as I put on my first comment, that was not the output I was getting out of it.

lox commented 5 years ago

Yeah, that's really strange 🤔 If you happen to see it again, send us the build and we will investigate!

pecigonzalo commented 5 years ago

I tried just now and this is working as expected, im confused as I had a build with it configured as described in the issue desc, but my build its now removed as I deleted the pipeline. If I can replicate again or find the build, ill post here. For now, this seems to be something else and not the plugin.

Thanks