GoSS

July 22, 2026 ยท View on GitHub

Interacts with GoSS.

Dependencies

  • GoSS CLI binary executable >= 0.4
  • DGoSS CLI binary exeuctable (validateDocker)

goss.add()

Add a single resource to the test suite.

goss.add(
  bin:         '/usr/bin/goss', // optional executable path for goss
  excludeAttr: ['checksums', 'owner'], // optional list of resource attributes to exclude
  gossfile:    'goss.yaml', // optional location of gossfile with included directive
  logLevel:    'info', // optional logging verbosity level; one of 'error', 'warn', 'info', 'debug', or 'trace'
  name:        '/etc/hosts', // name of the resource to add (e.g. filename, service name, port)
  package:    null, // optional package type to use (apk, dpkg, pacman, rpm)
  resource:    'file', // type of resource to add; must be one of 'package', 'file', 'addr', 'port', 'service', 'user', 'group', 'command', 'dns', 'process', 'http', 'goss', 'kernel-param', 'mount', or 'interface'
  vars:       'vars.yaml', // optional YAML or JSON vars file to use with gossfile
  varsInline: ['name':'value', 'name2':'value2'] // optional inline vars to use with gossfile (overwrites 'vars')
)

goss.autoadd(String version, String bin = 'goss')

Automatically add all matching resource to the test suite.

goss.autoadd('sshd', '/usr/local/bin/goss') // resource name for first argument

goss.render()

Renders a single valid GoSSfile from separated individual test files. This method will return the rendered GoSSfile as a String, and does not perform any further actions with the rendered content.

goss.render(
  bin:        '/usr/bin/goss', // optional executable path for goss
  debug:      false, // optional print rendered golang template prior to gossfile
  gossfile:   'goss.yaml', // optional location of gossfile with included directive
  logLevel:   'info', // optional logging verbosity level; one of 'error', 'warn', 'info', 'debug', or 'trace'
  package:    null, // optional package type to use (apk, dpkg, pacman, rpm)
  vars:       'vars.yaml', // optional YAML or JSON vars file to use with gossfile
  varsInline: ['name':'value', 'name2':'value2'] // optional inline vars to use with gossfile (overwrites 'vars')
)

goss.server()

Creates a persistent REST API endpoint with GoSS.

goss.server(
  bin:        '/usr/bin/goss', // optional executable path for goss
  cache:      '5s', // optional time to cache the results
  endpoint:   '/healthz', // optional endpoint to expose
  format:     'rspecish', // optional formatter to use for output
  formatOpts: 'perfdata', // optional extra formatter options (perfdata, pretty, or verbose)
  gossfile:   'goss.yaml', // optional location of gossfile
  logLevel:   'info', // optional logging verbosity level; one of 'error', 'warn', 'info', 'debug', or 'trace'
  maxConcur:  '50', // optional maximum number of tests to run concurrently
  package:    null, // optional package type to use (apk, dpkg, pacman, rpm)
  port:       '8080', // optional specified port to listen on
  vars:       'vars.yaml', // optional YAML or JSON vars file to use with gossfile
  varsInline: ['name':'value', 'name2':'value2'] // optional inline vars to use with gossfile (overwrites 'vars')
)

goss.validate()

Locally executes a gossfile with GoSS. This method will return a Boolean type indicating whether the validation was successful (true) or not (false).

goss.validate(
  bin:          '/usr/bin/goss', // optional executable path for goss
  format:       'rspecish', // optional formatter to use for output
  formatOpts:   'perfdata', // optional extra formatter options (perfdata, pretty, sort, or verbose)
  gossfile:     'goss.yaml', // optional location of gossfile
  logLevel:   'info', // optional logging verbosity level; one of 'error', 'warn', 'info', 'debug', or 'trace'
  maxConcur:    '50', // optional maximum number of tests to run concurrently
  package:      null, // optional package type to use (apk, dpkg, pacman, rpm)
  retryTimeout: '0s', // optional retry on failure so long as elapsed + `sleep` time is less than this value
  sleep:        '1s', // optional time to sleep between retries (ignored unless `retryTimeout` also specified)
  vars:         'vars.yaml', // optional YAML or JSON vars file to use with gossfile
  varsInline:   ['name':'value', 'name2':'value2'] // optional inline vars to use with gossfile (overwrites 'vars')
)

goss.validateDocker()

Locally executes a gossfile in a Docker container with DGoSS. Note that dgoss environment variables should be set in the environment block of a Jenkinsfile and will not be provided as as part of the interface to this method. That is also the process for providing arguments to goss when running inside the dgoss wrapper, so goss arguments cannot be directly interfaced in this method. Also note that dgoss runs a container, but does not stop the running container, so you may want to wrap the code inside a Image.withRun{} block for safety.

goss.validateDocker(
  bin:   '/usr/bin/dgoss', // optional executable path for dgoss
  flags: ['JENKINS_OPTS':'--httpPort=8080 --httpsPort=-1', 'JAVA_OPTS':'-Xmx1048m'], // optional flags for container run
  image: 'alpine:latest' // docker image to run container from
)

goss.validateGossfile(String gossfile)

Validates gossfile syntax. This method will return a Boolean type indicating whether the validation was successful (true) or not (false).

goss.validateGossfile('gossfile.yaml')