buildkite / feedback

Got feedback? Please let us know!
https://buildkite.com
25 stars 24 forks source link

Support export of bash functions in pre-command hooks #455

Closed moensch closed 6 years ago

moensch commented 6 years ago

Within pre-command hooks I can export variables and that's all fine. But if I export a function via export -f func_name it is then not available to the command step.

I have worked around this for now by converting the plugin I wrote to provide the bash func from a pre-command to a command hook (where the hook declares the function and calls export -f) and then simply calls eval "$BUILDKITE_COMMAND".

Though command hooks are rather limiting (no more than one).

lox commented 6 years ago

Because we have to support a wide variety of shells I think we're unlikely to do this. We have to handle each shell and figure out what env are exported to make them available to other hooks, I think adding functions would introduce too much complexity and we'd prefer folks handled shared code other ways.

Sounds like you are headed in the right direction with plugins! Check out https://github.com/buildkite-plugins/library-example-buildkite-plugin if you haven't seen it.

I'm going to close this one for now, feel free to let us know if I've missed something.

moensch commented 6 years ago

Oh - I did vaguely think about that as a use case (overriding $PATH) - that makes so much sense. Thank you. This solves my specific problem exactly (provide commands without taking over as a command hook).