Trailing newline may be missing when getting meta-data
When using a block step with a select-input and multiple=true, the keys of the selected options are set as meta-data with line-breaks as delimiters. Unfortunately, the last line is missing a trailing line-break. This can be quite error-prone when scripting in a POSIX shell, since the straightforward construction will silently leave the final line unprocessed:
buildkite-agent meta-data get selected_options | while read -r selection; do
echo "$selection was selected"
done
The documentation is not clear imo on whether this behavior is intentional:
When multiple options are selected, they are delimited in the meta-data field by a line break (\n).
It is in any case not consistent, since buildkite-agent meta-data keys uses also a \n as delimiter but includes a trailing \n as well.
It would probably a good idea if buildkite-agent meta-data get would always output a trailing new-line (on non-empty output, at least). I see how this could be potentially breaking for some people, maybe it could be protected by a flag.