---
name: "Ruby rbenv"
description: "Uses rbenv to manage Ruby versions in Buildkite agent hooks."
author: "buildkite"
repo: "ruby-rbenv-example"
stars: 5
demo: "https://buildkite.com/buildkite/ruby-rbenv-example/builds/latest?branch=main"
---

# Buildkite Ruby rbenv Example


This repository is an example [Buildkite](https://buildkite.com/) pipeline that demonstrates how to test a [Ruby](https://www.ruby-lang.org/en/) project using [rbenv](https://github.com/rbenv/rbenv).



See the full [Getting Started Guide](https://buildkite.com/docs/guides/getting-started) for step-by-step instructions on how to get this running.


<a href="https://buildkite.com/buildkite/ruby-rbenv-example/builds/latest?branch=main">
  <img width="2400" alt="Screenshot of example pipeline build page" src="https://raw.githubusercontent.com/buildkite/ruby-rbenv-example/main/.buildkite/screenshot.png" />
</a>

<!-- docs:start -->
## How it works

This example:
- Uses a [pre-command hook](https://github.com/buildkite/ruby-rbenv-example/blob/HEAD/.buildkite/hooks/pre-command) to load `rbenv`
- Runs Ruby tests using the version specified in `.ruby-version`

Key files:
- [`pre-command`](https://github.com/buildkite/ruby-rbenv-example/blob/HEAD/.buildkite/hooks/pre-command) – loads `rbenv` before each job runs
- [`pipeline.yml`](https://github.com/buildkite/ruby-rbenv-example/blob/HEAD/.buildkite/pipeline.yml) – defines the pipeline steps

See the [Agent hook documentation](https://buildkite.com/docs/agent/hooks) for more information about Buildkite’s agent hooks.

<!-- docs:end -->

## License

See [LICENSE.md](https://github.com/buildkite/ruby-rbenv-example/blob/HEAD/LICENSE.md) (MIT)