Plan on Pull Request

🚧

Currently, we support Plan on Pull Request for GitHub and GitLab repositories only. Support for Bitbucket is coming soon.

Pull Request Plan in env0

env0 allows you to control and monitor your infrastructural code changes via pull requests automation. When setting Pull Request Plan (aka PR Plan), your environment will automatically run a deployment consisting of only the Terraform Plan phase (without running the Terraform Apply) and share the results with you via a comment on your pull request. Pull Request Plan will run on every push to the opened pull request.

For a PR Plan to run automatically, the following prerequisites must be met:

  1. Environment has Pull Request Plan enabled.
  2. Environment is originated from a VCS integrated template, and its configured revision is the same as the base branch (aka target) of the opened pull request.

Enable Pull Request Plan

Go to your existing Environment in env0, and head over to the Triggers tab.
Enable the checkbox stating "Run Terraform Plan on Pull Requests targeting this branch".

You can choose to run by the following options:

  • Any change - your environment will receive PR Plan on every push
  • Changes on Template Directory files - your environment will receive PR Plan on every push which the push contains file changes under Terraform Folder
  • Changes by file filter pattern - your environment will receive PR Plan on every push which the push contains file changes by match to the pattern. see below how to configure glob pattern.

You can follow the Deployment History for deployments of PR Plan type:

📘

Plans in parallel

PR Plans do not lock the terraform state, and can be run in parallel.

If a bunch of PR Plans are queued in sequence, all of these PR Plans will run simultaneously when they reach their turn. If a deploy/destroy is queued after this batch of PR Plans, it will wait until all of those plans are finished before starting.

🚧

If the "PR plan" doesn't run because the push doesn't contain change files, we will mark the latest status of this PR that we got or skipped status if the Version Control supported it.

Pull Request Comments

env0 will make a comment on your pull request for three different reasons:

  1. When a PR Plan has started:
GitHubGitHub

GitHub

GitLabGitLab

GitLab

  1. When a PR Plan has finished successfully: (full log is attached under Plan Details)
GitHubGitHub

GitHub

GitLabGitLab

GitLab

BitbucketBitbucket

Bitbucket

  1. When a PR Plan has failed:
GitHubGitHub

GitHub

GitLabGitLab

GitLab

BitbucketBitbucket

Bitbucket

GitHub Commit Status Checks

env0 will set a status check on the commit you want to merge in the pull request
We will make the status as failing when the run had failed to generate a Terraform plan, and successful when a plan was generated.

  1. When we push the "Pr plan" to the queue
  1. When we start running "Pr Plan" - Notice - in case you didn't approve the previous deploy we will wait until then
  1. When a Terraform plan was generated:
  1. When the run was not able to generate a proper Terraform plan:
  1. If you linked your PR to multiple environments you will get the summary of all the PR Plans

By pressing on Details Github will forward you to the Checks tab

and by pressing View more details on env0 you will be forward to your environment on env0

GitLab Pipelines

env0 will run set a GitLab pipeline and job status on the commit you want to merge in the merge request.
We will show its status 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 env0 pipeline run statusA Merge Request and its associated env0 pipeline run status

A Merge Request and its associated env0 pipeline run status

Clicking the pipeline on the Merge Request will reveal which env0 environment deployments were triggers, and their status.
Clicking the status will take you back to env0, where you can see more details on this automatic plan run.

  1. When we start run "Pr plan" we mark "in progress" the commit
  1. When a Terraform plan was generated:
  1. When the run was not able to generate a proper Terraform plan:
A Merge Request pipeline jobs  running for each env0 environmentA Merge Request pipeline jobs  running for each env0 environment

A Merge Request pipeline jobs running for each env0 environment

Bitbucket Commit Build Status

env0 will set a status check on the commit you want to merge in the pull request.
We will set the status as failing when the run had failed to generate a Terraform plan, and successful when a plan was generated.

  1. When we start run "Pr plan" we mark "in progress" the commit
  1. When a Terraform plan was generated:
  1. When the run was not able to generate a proper Terraform plan:

Did this page help you?