Files
Packer-Cn/website/content/docs/templates/hcl_templates/path-variables.mdx
50da6c8dc8 docs: Migrate link formats (#12192)
* Adding check-legacy-links-format workflow

* Adding test-link-rewrites workflow

* Migrating links to new format

* Updating docs-content-check-legacy-links-format hash

* chore: update source

* Update generated partials from Packer plugin SDK

* Bump packer-plugin-sdk to get latest packer-sdc

* Update website/content/docs/templates/hcl_templates/blocks/build/provisioner.mdx

* Update Plugin SDK to fix shell-local regression

---------

Co-authored-by: Kendall Strautman <[email protected]>
Co-authored-by: Wilken Rivera <[email protected]>
Co-authored-by: Kendall Strautman <[email protected]>
2023-01-27 09:47:08 -08:00

41 lines
1.2 KiB
Plaintext

---
page_title: Path Variables - HCL Configuration Language
description: |-
Special variables provide directory information. This page covers all path
variables.
---
`@include 'path/separator-note.mdx'`
# Path variables
- `path.cwd`: the directory from where Packer was started.
- `path.root`: the directory of the input HCL file or the input folder.
## Examples
```HCL
locals {
settings_file = "${path.cwd}/settings.txt"
scripts_folder = "${path.root}/scripts"
root = path.root
}
```
## Related Functions
- [`abspath`](/packer/docs/templates/hcl_templates/functions/file/abspath) takes a string containing
a filesystem path and converts it to an absolute path.
- [`basename`](/packer/docs/templates/hcl_templates/functions/file/basename) returns _only_ the last
portion of a filesystem path, discarding the portion that would be returned
by `dirname`.
- [`fileset`](/packer/docs/templates/hcl_templates/functions/file/fileset) enumerates a set of
regular file names given a path and pattern.
- [`dirname`](/packer/docs/templates/hcl_templates/functions/file/dirname) returns all of the
segments of a filesystem path _except_ the last, discarding the portion that
would be returned by `basename`.