Attaching Files And Artifacts

Build and test processes often produce files that are useful to keep around. For example, installable application packages, report files, logs, and screenshots.

The Solano worker will automatically collect files in a few well-known locations. These files will be automatically attached to the build report.

To take advantage of this functionality for your own custom attachments, you have two options: use the file collection pattern in your configuration file or make sure that the files you want to attach to the build are moved or copied to Solano’s collection paths. You can update your build configuration with a post-worker hook, or implement test cleanup hooks according to your test framework.

Using a Pattern

The simplest way to attach user-defined files to a build report is to specify a list of patterns in your build configuration. Patterns are shell globs; if a pattern matches a directory the directory will uploaded as a gzipped tar file.

---
collect:
  repo:                   # Paths are relative to repository
    - coverage            # Directories will be saved as gzipped tar
    - config/solano.yml

Using a Post-Worker Hook

Files can either be attached to a specific test, or to the whole build.

The following paths are defined in terms of Unix environment variables that will be set when your build is running.

Path Scope
$HOME/results/$TDDIUM_SESSION_ID/session Attached to build/session
$HOME/results/$TDDIUM_SESSION_ID/$TDDIUM_TEST_EXEC_ID Attached to test (captured immediately after test finishes)

Examples:

Attaching a screenshot to the build:

hooks:
  post_worker: "cp reports/example-abcdef-screenshot.png $HOME/results/$TDDIUM_SESSION_ID/session/"

Attaching a multi-file HTML report to the build:

hooks:
  post_worker: "(cd reports/lint && tar cf $HOME/results/$TDDIUM_SESSION_ID/session/lint.tgz .)"

Ruby Bindings

The solano ruby gem provides convenience methods for attaching files.

Using the gem’s BuildAgent module, you can attach files to the session or to a particular test’s output.

#!/usr/bin/env ruby
require 'solano/agent'

agent = Solano::BuildAgent.new
# Attach /etc/hosts as hosts to the current session
agent.attach_file('/etc/hosts')

# Attach /etc/resolv.conf as resolv.conf to the current test
agent.attach_file('/etc/resolv.conf', {:exec_id => agent.test_exec_id})