How to add a plugin to all agents

When using Elastic Stack you can see that there are global plugins like ECR being used that are just part of the default agent flow. How can I add my own plugins to this flow on the agents? That is to say, I want a plugin with a post-checkout script that I want to run on all agents just like how the ECR plugin does.

Where to I put the plugins on the agent and how do I get the agent to use them?

Thanks!

Hi @peerallan,
Great question about adding global plugins to your Elastic CI Stack agents.

The most straightforward approach is to use a bootstrap script with the BootstrapScriptUrl parameter. In your bootstrap script, you can install your plugin and create a post-checkout hook in /etc/buildkite-agent/hooks/. Something like:

#!/bin/bash
# Your bootstrap script
cat > /etc/buildkite-agent/hooks/post-checkout <<'EOF'
#!/bin/bash
# Your plugin logic here
EOF
chmod +x /etc/buildkite-agent/hooks/post-checkout

If your plugin logic is more complex, you could have the bootstrap script pull the actual plugin code from S3 or another source and then set it up in the post-checkout hook.

For a more permanent solution, you could also build your own custom AMI with the plugins pre-installed, similar to how the ECR plugin is included. This is actually how the ECR plugin you mentioned is configured.

Quick question though - what specific functionality are you looking to add with your global plugin? Knowing your use case might help me suggest the best approach for your situation.