Skip to main content
fileset(path, pattern) returns a set of file paths matching pattern within path. The paths are relative to path. The set is unordered; use sort when order matters.

Signature

fileset(path string, pattern string) set(string)
pattern supports * (any characters except /), ** (any path components), and ? (any single character).

Example

Discover all SQL migration files and run them in alphabetical order:
computed "migrations" {
  description = "All SQL migration files"
  expression  = fileset(".", "migrations/*.sql")
}

task "migrate" {
  description = "Apply all pending migrations"
  commands = [
    "for f in ${join(" ", sort(computed.migrations))}; do psql -f $f && echo \"Applied $f\"; done",
  ]
}
All .sql files under migrations/ are discovered and applied in alphabetical order, which corresponds to their numeric prefix order (e.g., 001_init.sql, 002_users.sql).

Notes

  • The returned paths are relative to path, not to the playbook directory.
  • Use sort when you need a deterministic traversal order.
  • Hidden files (starting with .) are not included unless the pattern explicitly matches them.
  • Only files are returned, not directories.