2016-10-27 12:18:41 +00:00
# Getting started with Review Apps
2016-10-19 09:55:46 +00:00
> [Introduced][ce-21971] in GitLab 8.12. Further additions were made in GitLab 8.13.
2016-10-27 12:18:41 +00:00
>
Inspired by [Heroku's Review Apps][heroku-apps] which itself was inspired by
[Fourchette].
2016-10-19 09:55:46 +00:00
2016-10-27 12:18:41 +00:00
The base of Review Apps is the [dynamic environments] which allow you to create
a new environment (dynamically) for each one of your branches.
2016-10-19 09:55:46 +00:00
2016-10-27 12:18:41 +00:00
A Review App can then be visible as a link when you visit the [merge request]
relevant to the branch. That way, you are able to see live all changes introduced
by the merge request changes. Reviewing anything, from performance to interface
changes, becomes much easier with a live environment and as such, Review Apps
can make a huge impact on your development flow.
2016-10-19 09:55:46 +00:00
2016-10-27 12:18:41 +00:00
They mostly make sense to be used with web applications, but you can use them
any way you'd like.
2016-10-19 09:55:46 +00:00
2016-10-27 12:18:41 +00:00
## Overview
2016-10-27 13:31:06 +00:00
Simply put, a Review App is a mapping of a branch with an environment as there
is a 1:1 relation between them.
Here's an example of what it looks like when viewing a merge request with a
dynamically set environment.
![Review App in merge request ](img/review_apps_preview_in_mr.png )
In the image above you can see that the `add-new-line` branch was successfully
built and deployed under a dynamic environment and can be previewed with an
also dynamically URL.
---
2016-10-27 12:18:41 +00:00
To get a better understanding of Review Apps, you must first learn how
environments and deployments work. The following docs will help you grasp that
knowledge:
1. First, learn about [environments][] and their role in the development workflow.
1. Then make a small stop to learn about [CI variables][variables] and how they
can be used in your CI jobs.
1. Next, explore the [`environment` syntax][yaml-env] as defined in `.gitlab-ci.yml` .
This will be your primary reference when you are finally comfortable with
how environments work.
1. Additionally, find out about [manual actions][] and how you can use them to
deploy to critical environments like production with the push of a button.
2016-10-27 13:31:06 +00:00
1. And as a last step, follow the [example tutorials ](#examples ) which will
2016-10-27 12:18:41 +00:00
guide you step by step to set up the infrastructure and make use of
2016-10-27 13:31:06 +00:00
Review Apps.
2016-10-27 12:18:41 +00:00
## Configuration
For configuration examples see the [dynamic environments] documentation.
## Creating and destroying Review Apps
The creation and destruction of a Review App is defined in `.gitlab-ci.yml` .
Check the [environments] documentation how to do so.
## A simple workflow
The process of adding Review Apps in your workflow would look like:
1. Set up the infrastructure to host and deploy the Review Apps.
1. Install and configure a Runner that does the deployment.
1. Set up a job in `.gitlab-ci.yml` that uses the predefined
[predefined CI environment variable][variables] `${CI_BUILD_REF_NAME}` to
create dynamic environments and restrict it to run only on branches.
1. Optionally set a job that stops the Review Apps.
From there on, you would follow the branched Git flow:
1. Push a branch and let the Runner deploy the Review App based on the `script`
definition of the dynamic environment job.
1. Wait for the Runner to build and/or deploy your web app.
1. Click on the link that's present in the MR related to the branch and see the
changes live.
2016-10-27 13:31:06 +00:00
## Distinguish between production and review apps
1. We need some form to distinguish between production/staging and review app environment,
- Are dynamic environments distinguishable by the slash in `environment:url` ?
We would expect the environments to be of `type/name` :
1. This would allow us to have a clear distinction between different environment types: `production/gitlab.com` , `staging/dev` , `review-apps/feature/branch` ,
3. We would be aware of some of these types and for example for `review-apps` show them differently in context of Merge Requests, ex. calculating `deployed ago` a little differently.
## Limitations
2016-10-27 12:18:41 +00:00
We are limited to use only [CI predefined variables][variables].
2016-10-19 09:55:46 +00:00
2016-10-27 12:18:41 +00:00
## Examples
A list of examples used with Review Apps can be found below:
2016-10-19 09:55:46 +00:00
2016-10-27 12:18:41 +00:00
- [Use with NGINX][app-nginx] - Use NGINX and the shell executor of GitLab Runner
to deploy a simple HTML website.
2016-10-19 09:55:46 +00:00
2016-10-27 12:18:41 +00:00
And below is a soon to be added examples list:
2016-10-19 09:55:46 +00:00
2016-10-27 12:18:41 +00:00
- Use with Amazon S3
- Use on Heroku with dpl
- Use with OpenShift/kubernetes
2016-10-19 09:55:46 +00:00
2016-10-27 14:03:56 +00:00
[app-nginx]: https://gitlab.com/gitlab-examples/review-apps-nginx
2016-10-19 09:55:46 +00:00
[ce-21971]: https://gitlab.com/gitlab-org/gitlab-ce/issues/21971
2016-10-27 12:18:41 +00:00
[dynamic environments]: ../environments.md#dynamic-environments
2016-10-19 09:55:46 +00:00
[environments]: ../environments.md
[fourchette]: https://github.com/rainforestapp/fourchette
2016-10-27 12:18:41 +00:00
[heroku-apps]: https://devcenter.heroku.com/articles/github-integration-review-apps
[manual actions]: ../environments.md#manual-actions
[merge request]: ../../user/project/merge_requests.md
[variables]: ../variables/README.md
[yaml-env]: ../yaml/README.md#environment