1. Resources
  2. /
  3. Blog
  4. /
  5. Terminal: Open source ANSI to HTML renderer

Terminal: Open source ANSI to HTML renderer

1 minute read

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.

1
$ 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/.


Related posts

Start turning complexity into an advantage

Create an account to get started with a 30-day free trial. No credit card required.

Buildkite Pipelines

Platform

  1. Pipelines
  2. Pipeline templates
  3. Public pipelines
  4. Test Engine
  5. Package Registries
  6. Mobile Delivery Cloud
  7. Pricing

Hosting options

  1. Self-hosted agents
  2. Mac hosted agents
  3. Linux hosted agents

Resources

  1. Docs
  2. Blog
  3. Changelog
  4. Webinars
  5. Plugins
  6. Case studies
  7. Events

Company

  1. About
  2. Careers
  3. Press
  4. Brand assets
  5. Contact

Solutions

  1. Replace Jenkins
  2. Workflows for AI/ML
  3. Testing at scale
  4. Monorepo delivery

Support

  1. System status
  2. Forum