docker-compose-buildkite-plugin
docker-compose-buildkite-plugin copied to clipboard
2.6.0 release breaks commands with heredocs
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.
Sorry about this @bjeanes!
I've been meaning to apply the same approach we took in https://github.com/buildkite-plugins/docker-buildkite-plugin/pull/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!
See https://github.com/buildkite-plugins/docker-compose-buildkite-plugin/pull/186 for context.
From what I can see, multi-line commands were added to unit tests of the plugin as well as the actual pipeline (see https://github.com/buildkite-plugins/docker-compose-buildkite-plugin/commit/b96db48dad06d2f858d4d089390268c68909711f ) to prevent regressions. Let us know if something is stll not working, though