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

2.6.0 release breaks commands with heredocs #185

Closed
bjeanes opened this issue Dec 25, 2018 · 3 comments
Closed

2.6.0 release breaks commands with heredocs #185

bjeanes opened this issue Dec 25, 2018 · 3 comments

Comments

@bjeanes
Copy link

bjeanes commented Dec 25, 2018

Probably related to #165 (which I fully support) but as an FYI to others and a place to discuss fixes/workarounds, I'm opening this issue.

Previously, if you needed to run multiple commands (e.g. foo1 -x; bar2 -y), docker-compose-buildkite-plugin would parse this as docker-compose run image "foo1 -x"; bar2 -y (i.e. your second command didn't run in container).

My workaround in some cases has been to use heredocs:

steps:
  # ...
  - name: 'Annotate outdated Yarn deps'
    command: |
      bash <<EOS
        echo $(yarn bin)
        yarn outdated
        yarn outdated --json | node_modules/.bin/format-yarn-outdated --format markdown | tee yarn-outdated.md
        cat yarn-outdated.md | buildkite-agent annotate --style warning --context yarn
      EOS
    artifact_paths: 'yarn-outdated.md'
    plugins:
      docker-compose#v2.5.1:
        run: tests
        config: .buildkite/docker-compose.yml
        volumes:
          - ${BUILDKITE_AGENT_BINARY_PATH:-/usr/bin/buildkite-agent}:/usr/bin/buildkite-agent
        environment:
          - BUILDKITE_AGENT_ACCESS_TOKEN
          - BUILDKITE_BRANCH
          - BUILDKITE_BUILD_ID
          - BUILDKITE_COMMIT
          - BUILDKITE_JOB_ID

These commands no longer parse with the command parsing change:

bash: <<EOS: No such file or directory

(example failing step for BK team: https://buildkite.com/covidence/app/builds/2767#65db24e2-c53a-433f-b826-3881bf9e0d19)

I think, ultimately, these should probably be extracted out into separate scripts anyway, so this isn't a huge problem, but it probably is a good FYI for others and another command use-case that could have been tested to catch this.

@lox
Copy link
Contributor

lox commented Dec 26, 2018

Sorry about this @bjeanes!

I've been meaning to apply the same approach we took in buildkite-plugins/docker-buildkite-plugin#68 to this plugin.

I believe with that logic, your command would be interpreted to be:

/bin/sh -e -c "bash <<EOS
  echo $(yarn bin)
  yarn outdated
  yarn outdated --json | node_modules/.bin/format-yarn-outdated --format markdown | tee yarn-outdated.md
  cat yarn-outdated.md | buildkite-agent annotate --style warning --context yarn
EOS"

That should work fine!

@lox
Copy link
Contributor

lox commented Dec 26, 2018

See #186 for context.

@toote
Copy link
Contributor

toote commented Sep 21, 2022

From what I can see, multi-line commands were added to unit tests of the plugin as well as the actual pipeline (see b96db48 ) to prevent regressions. Let us know if something is stll not working, though

@toote toote closed this as completed Sep 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants