Skip to main content
fileexists(path) returns true if a file exists at path, and false otherwise. The path is relative to the playbook’s working directory.

Signature

Example

Install dependencies only when a lock file is present, skipping the step entirely when it is not:
When package-lock.json does not exist, the install task is skipped. build still runs but with no prior install step.

Notes

  • fileexists only returns true for regular files. Passing a path to a directory or other non-regular file returns an error, not false.
  • The path is relative to the playbook’s working directory at evaluation time.
  • Use fileexists in condition to make a task conditional on the presence of a configuration file, lock file, or generated artifact.