|
| 1 | +# Ignoring Files and Directories from Pipelines Runs |
| 2 | + |
| 3 | +## Introduction |
| 4 | + |
| 5 | +Pipelines allows you to ignore specific files and directories so that changes to them do not trigger plan or apply runs. This is especially useful for excluding documentation, test data, or other files that should not affect your infrastructure deployments, helping you reduce unnecessary CI/CD runs and noise in your workflow. |
| 6 | + |
| 7 | +## Setting up the Ignore List |
| 8 | + |
| 9 | +To set up the ignore list, you can add it to your Pipelines configuration using either HCL or YAML. For example, in HCL, you would add an `ignore_list` field to your `.gruntwork/pipelines.hcl` configuration: |
| 10 | + |
| 11 | +```hcl |
| 12 | +repository { |
| 13 | + ignore_list = "README.md,docs/**.md,local-testing/**" |
| 14 | + # ... other config ... |
| 15 | +} |
| 16 | +``` |
| 17 | + |
| 18 | +Or, in YAML, you would add an `ignore-list` field to your `.gruntwork/config.yml`: |
| 19 | + |
| 20 | +```yaml |
| 21 | +pipelines: |
| 22 | + ignore-list: "README.md,docs/**.md,local-testing/**" |
| 23 | + # ... other config ... |
| 24 | +``` |
| 25 | + |
| 26 | +The patterns you use in the ignore list are always relative to the repository root, and you can combine multiple patterns by separating them with commas. |
| 27 | + |
| 28 | +For more details and the full syntax, see the [Ignore List Reference](/2.0/reference/pipelines/ignore-list). |
| 29 | + |
| 30 | +:::note |
| 31 | +The ignore list supports two types of wildcards: `*` and `**`. |
| 32 | + |
| 33 | +- The single asterisk `*`, matches any character **except** the directory separator `/` - this allows you to match file and directory names at a specific depth. |
| 34 | +- The double asterisk `**` matches any character, **including** `/` - this allows you to match files and directories at any depth. |
| 35 | + |
| 36 | +E.g. `a/*-dev/b` will match `a/my-dev/b` but not `a/b/c/my-dev/b`. |
| 37 | +::: |
| 38 | + |
| 39 | +## Practical example |
| 40 | + |
| 41 | +Let's walk through a practical example. Suppose you want to ensure that changes to any `README.md` file — whether at the root or in any subdirectory — do not trigger Pipelines runs. First, use the pattern `README.md` to match the file at the root of your repository. Next, add `**/README.md` to match any `README.md` file in any subdirectory, at any depth. Combine these patterns with a comma: `README.md,**/README.md`. Your configuration would look like this in HCL: |
| 42 | + |
| 43 | +```hcl |
| 44 | +repository { |
| 45 | + ignore_list = "README.md,**/README.md" |
| 46 | +} |
| 47 | +``` |
| 48 | + |
| 49 | +Or in YAML: |
| 50 | + |
| 51 | +```yaml |
| 52 | +pipelines: |
| 53 | + ignore-list: "README.md,**/README.md" |
| 54 | +``` |
| 55 | +
|
| 56 | +:::note |
| 57 | +Why do we need to use two patterns, not just `**README.md`? |
| 58 | + |
| 59 | +We need to include a directory separator after the `**` so that if any other files _happened_ to end with `README.md` they would not be matched. By adding the directory separator we are no longer matching the root `README.md` file, so we need to add both patterns. |
| 60 | +::: |
0 commit comments