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

Don't overwrite BUILDKITE_METAHOOK_HOOKS_PATH, and shard vars by plugin configuration #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

staticfloat
Copy link

@staticfloat staticfloat commented Jun 14, 2021

Changes

If we have multiple metahook instances, let's not generate multiple temporary directories; instead just create one (and only dump the environment variables once). We also shard the vars file by the plugin configuration (calculating a hash using the standard cksum utility) so that you can have multiple metahook instances each with their own configuration (which is implicitly stored in the vars file).

I'm not sure why the vars file is created at all, as it seems it could be dynamically probed with [[ -v "BUILDKITE_PLUGIN_METAHOOK_${upperd}" ]] instead of using the grep on the vars file (since the variables should be live in the environment when the hook is actually executed), but I kept the current behavior.

Verification

This fixed an issue with multiple metahook instances in a pipeline of mine.

If we have multiple `metahook` instances, let's not generate multiple
temporary directories; instead just create one (and only dump the
environment variables once).

This fixed an issue with multiple `metahook` instances in a pipeline of
mine.
By hashing the `BUILDKITE_PLUGIN_CONFIGURATION` envvar, we can
effectively disambiguate multiple instances of the `metahook` plugin
within a single pipeline.  This allows us to seprate the `vars` file, as
it otherwise can get confused if you have multiple invocations of the
plugin that each use different hooks.
@staticfloat staticfloat changed the title Don't overwrite BUILDKITE_METAHOOK_HOOKS_PATH Don't overwrite BUILDKITE_METAHOOK_HOOKS_PATH, and shard vars by plugin configuration Jun 14, 2021
@osamahassani05355881581

Changes

If we have multiple metahook instances, let's not generate multiple temporary directories; instead just create one (and only dump the environment variables once). We also shard the vars file by the plugin configuration (calculating a hash using the standard cksum utility) so that you can have multiple metahook instances each with their own configuration (which is implicitly stored in the vars file).

I'm not sure why the vars file is created at all, as it seems it could be dynamically probed with [[ -v "BUILDKITE_PLUGIN_METAHOOK_${upperd}" ]] instead of using the grep on the vars file (since the variables should be live in the environment when the hook is actually executed), but I kept the current behavior.

Verification

This fixed an issue with multiple metahook instances in a pipeline of mine.

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

Successfully merging this pull request may close these issues.

None yet

2 participants