Images in Log Output

You can embed external images or images generated by your builds, directly into your logs using a special ANSI escape code.

Syntax for Inlining Images

The syntax for inlining images follows other ANSI escape codes (for example, setting text color) but uses the code 1338. A url is required, and you can optionally specify an alt attribute to describe what the image is.

The following Bash function takes an image URL and alternative text and will output the correct escape code sequence:

function inline_image {
  printf '\033]1338;url='"$1"';alt='"$2"'\a\n'
}

You can use it like so:

inline_image 'https://media0.giphy.com/media/8Ry7iAVwKBQpG/giphy.gif' 'Rainbows'

When rendered in Buildkite (via our open-source Terminal library) it will look like this:

External image

When you run the script locally you won't see any output because your terminal will ignore the escape code. If you pipe your build script to more you can see the raw escape codes.

Inlining Build Artifact Images

You can inline artifact images by using the artifact:// URL syntax. For example you can inline the following artifact:

Artifact path

by using the following URL:

inline_image 'artifact://tmp/images/omg.gif' 'OMG'

Be careful to ensure the part of the URL after artifact:// exactly matches the path you see in the Artifacts tab (e.g. it can't have a preceding ./).

The image artifact does not have to be uploaded at the time it’s written to the build log. If the artifact has not been uploaded you'll see a loading placeholder, and as soon as it's ready the image will automatically appear.

Library Support

  • The capybara-inline-screenshot Ruby gem will automatically inline screenshots of your integration test failures and also supports the iTerm image format for viewing failures directly in your terminal. When run under CI it automatically uses the artifact:// URL format.
    Ruby gem

Base64 Encoded Images

If you want to embed an image using base64 you can use iTerm’s image format, though you’ll need to keep in mind the log output limits. Where possible we recommend not using this format, but instead uploading the image as a build artifact and referencing it using the artifact:// URL.