Use Case
I need to clean up a bare metal (non-virtualized) agent after a build completes, but before the agent returns to the pool as available. Currently, I can only clean up at the beginning of each build, which adds extra waiting time to the CI process.
Proposed Solution
An ‘after-exit’ hook that runs after a job finishes but before the agent becomes available again. This would allow for:
- More responsive CI: When one build finishes, the agent could enter a “cleanup” state while other available agents take new requests immediately.
- Time savings: This approach could save 1-2 minutes of waiting time, especially when the build queue is semi-full.
- Efficient resource management: Cleanup happens “off the clock”, not impacting build times.
Current Limitations
If I understand correctly, the existing hooks (like ‘pre-exit’ or ‘pre-bootstrap’) would delay the current job or the next job, which isn’t ideal for maintaining CI responsiveness.
Request
Could the Buildkite team consider implementing an ‘after-exit’ agent hook? This would run after a job completes but before the agent returns to the available pool.
Thank you for considering this feature request in advance. If such feature already exists, I’d be grateful for any information.