Pull Request Plan in env zero
env zero allows you to control and monitor your infrastructure code changes with pull request automation. When setting Pull Request Plan (PR Plan), your environment will automatically run a deployment consisting of only the Plan phase (without applying any infrastructure changes) and share the results with you via a comment on your pull request. Pull Request Plan will run on every push to an open pull request.For a PR Plan to run automatically, the following prerequisites must be met:
- The environment has Pull Request Plan enabled
- The environment originated from a VCS-integrated template, and its configured revision is the same as the branch (target) of the pull request
- GitHub Integration - is currently the only VCS supporting forks (from private repositories only)
Enable Pull Request Plan
Go to your existing Environment in env zero and head to the Settings tab.Under Continuous Deployment, enable Run Terraform Plan on Pull Requests targeting this branch.

- Any change - your environment will receive a PR Plan on every push to the repository.
- Changes on Template Directory files - your environment will receive a PR Plan on every push that contains file changes under the Template folder
- Changes by file filter pattern - your environment will receive a PR Plan on every push containing file changes by matching them to the pattern. See below how to configure the glob pattern.

Glob patternGlob patterns specify sets of filenames with wildcard characters. For example, *.txt or my_folder/**It means you can configure pattern by git repository which re-deploy environment only if the push contains files that change by free pattern.You can configure patterns by Git repository which re-deploy an environment only if the push contains files that change by free pattern.For example, to configure a pattern like src/project_1/**
you should re-deploy only if the push contains files that start with src/project_1/…env zero also supports extglob patterns. These allow you to write a pattern that ignores files or uses a list of folders.When using OR/AND statements with extglob, make sure to:
- Wrap each option in parentheses
- Avoid unnecessary spaces - do not add spaces between the different glob pattern options
!(third/path/\*\*)+(first/path/**|second/path/myfile.txt)
This means we will match any change in first/path and second/path/myfile.txt, and ignore changes under third/path. (It is recommend to add exclusions first)+(Terraform/!(prod)**|Terragrunt/dev/**)
Match any changes inTerraform
orTerragrunt/dev
but ignore any changes inTerraform/prod
PR Plans ConcurrencyPR Plans do not lock the Terraform state, and can be in parallel. If a bunch of PR Plans are queued in sequence, they will all run simultaneously.
Status ChecksWhen the PR Plan completes, aside from commenting with the plan itself, your commit will be marked with a passing status check. In case the PR Plan failed, the commit status will be failure.If the PR Plan doesn’t run because the push didn’t contain changed files, env zero will mark the latest commit as skipped ( if the Version Control supports it). Additional policy configuration can be found under Do Not Report Skipped Status Check.
PR Plans from Merge CommitsIn order to control whether Merge Commits will trigger PR Plans, see Skip PR Plan on Merge Commits
Pull Request Comments
env zero will make a comment on your pull request for three different reasons:- When a PR Plan has started:

GitLab

Azure DevOps
- When a PR Plan has finished successfully (full log is attached under Plan Details)

GitHub

GitLab

Bitbucket

Azure DevOps
- When a PR Plan has failed:

GitHub

GitLab

Bitbucket

Azure DevOps
- Rerun a PR Plan:
you can rerun a PR plan deployment, the newly created deployment will be an exact snapshot in terms of commits and code source of the original Pr plan.

GitHub Commit Status Checks
env zero will set a status check on the commit you want to merge in the pull request. The status will be changed to ‘failed’ when the run had failed to generate a Terraform plan, and ‘successful’ when a plan was generated.- When the PR plan is pushed to the queue:

- When a PR Plan starts running (this will not happen until you approve the previous deployment):

- When a Terraform plan was generated:

- When the run was not able to generate a proper Terraform plan:

- If you linked your PR to multiple environments you will get the summary of all the PR Plans


GitLab Pipelines
env zero will run set a GitLab pipeline and job status on the commit you want to merge in the merge request.The status will be shown as ‘failed’ when the run had failed to generate a Terraform plan, and ‘successful’ when a plan was generated.

A Merge Request and its associated env zero pipeline run status
- When a PR Plan starts running, the commit will be labeled ‘in progress’:

- When a Terraform plan was generated:

- When the run was not able to generate a proper Terraform plan:

Bitbucket Commit Build Status
env zero will set a status check on the commit you want to merge in the pull request. The status will be set to ‘failing’ when the run had failed to generate a Terraform plan, and ‘successful’ when a plan was generated.- When the PR Plan starts running, the commit will be labeled as ‘in progress’:

- When a Terraform plan was generated:

- When the run was not able to generate a proper Terraform plan:

Azure DevOps PR Status
env zero will set a status check on your pull request.The status will be set to ‘failing’ when the run had failed to generate a Terraform plan, and ‘successful’ when a plan was generated.
- When the PR Plan starts running, the PR status will be labeled ‘pending’.

- When a Terraform plan was generated:

- When the run was not able to generate a proper Terraform plan:

Rerun a PR Plan
You can rerun a PR Plan deployment on the deployment page.The newly created deployment will be an exact snapshot of the commits and code source of the original PR Plan.
This will recreate the comment on the PR and the status checks.
