Introduction
This article addresses an issue where VCS-driven workspaces in HCP Terraform fail to trigger runs despite changes made in the repository that match the defined trigger patterns in the workspace settings.
Background
HCP Terraform integrates with your version control system (VCS) using its API to detect changes in your repository.
When the “Only trigger runs when files in specified paths change” option is enabled in workspace settings, Terraform will only trigger runs for changes that affect files or directories matching the specified paths. These paths are defined using trigger patterns (e.g., test/testapps/**/*
) under the VCS Triggers section of Workspace Settings > Version Control.
Problem
In a VCS-connected workspace, runs are expected to trigger automatically when changes are made to specific paths defined by trigger patterns. However, despite updating files within the expected path, no runs are triggered.
The following configuration is in place:
VCS trigger option: Only trigger runs when files in specified paths change
Trigger pattern:
test/testapps/**/*
Files being changed:
.auto.tfvars
files within thetest/testapps/
directory
VCS Repo structure :
Despite making changes to the expected files, runs are not being triggered.
Cause
- This issue occurs because of an unintended space or formatting error when entering the trigger pattern. In the backend, this results in an incorrectly formatted value such as
{modules/**/*,"test/testapps/**/* "}
The additional quotation marks are caused by invisible leading or trailing spaces when saving the path, preventing the trigger from working correctly.
Solutions:
Navigate to the Workspace Settings > Version Control section.
Remove the existing trigger path (
test/testapps/**/*
).Carefully re-add the pattern
test/testapps/**/*
, ensuring no leading or trailing spaces are included.Save the changes and re-trigger a run by making changes to the relevant files.
Outcome
After correcting the trigger path formatting, HCP Terraform should correctly recognise file changes in the specified path and trigger runs as expected.
Additional Information
- Only trigger runs when files in specified paths change
- Glob Patterns for Automatic Run Triggering
- If you're still experiencing issues, please contact HCP Terraform Support by submitting a ticket through our support portal