NewBuildkite hosted agents. Check out the Q1 Release for the latest features, including managed CI/CD offerings for Mac and Linux.

Terminal: Open source ANSI to HTML renderer


Today, we're open sourcing Terminal, the Ruby library behind our rendering of job logs.

$ gem install terminal

Terminal makes it easy to take arbitrary shell output, and turn it into beautifully rendered HTML. It has a simple API:

require "terminal" Terminal.render("...")

Terminal also ships with a command line utility, making it easy to test what the output will look like from the command line. For example, you can pipe rspec output to it:

$ rspec --color --tty | terminal

This will output the rendered HTML. That's not very useful by itself, but if you pass the --preview flag, it will render the output in a browser for you to view.

$ rspec --color --tty | terminal --preview

If some of your job logs look weird on Buildkite, you can use Terminal to help us debug the problem. First install jq, if you have Homebrew installed, you can just brew install jq.

Then, you can:

$JOB_LOG_URL="https://api.buildkite.com/v2/organizations/[org]/pipelines/[pipeline]/builds/[build]/jobs/[job]/log" echo $(curl -H "Authorization: Bearer [api-key]" $JOB_LOG_URL -s | jq '.content') | terminal

Once you've identified a problem, submit an issue, or if you're feeling adventurous, submit a Pull Request and contribute to Buildbox! :)

For more information on the Buildbox Builds API, see: https://buildkite.com/docs/api/builds.

You can check out Terminal on our GitHub repository: https://github.com/buildkite/terminal-to-html/.