index.md 5,1 КБ
Newer Older
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
1
# Getting started with Review Apps
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
2

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
3
>
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
4
5
6
7
- [Introduced][ce-21971] in GitLab 8.12. Further additions were made in GitLab
  8.13 and 8.14.
- Inspired by [Heroku's Review Apps][heroku-apps] which itself was inspired by
  [Fourchette].
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
8

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
9
The basis of Review Apps is the [dynamic environments] which allow you to create
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
10
a new environment (dynamically) for each one of your branches.
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
11

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
12
13
14
15
16
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.
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
17

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
18
19
They mostly make sense to be used with web applications, but you can use them
any way you'd like.
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
20

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
21
22
## Overview

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
23
24
25
26
27
28
29
30
31
32
33
34
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.

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
35
The details of the Review Apps implementation depend widely on your real
Ismail S's avatar
Ismail S включено в состав коммита
36
technology stack and on your deployment process. The simplest case is to
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
37
38
39
40
41
42
43
44
deploy a simple static HTML website, but it will not be that straightforward
when your app is using a database for example. To make a branch be deployed
on a temporary instance and booting up this instance with all required software
and services automatically on the fly is not a trivial task. However, it is
doable, especially if you use Docker, or at least a configuration management
tool like Chef, Puppet, Ansible or Salt.

## Prerequisites
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
45
46
47
48
49
50
51
52
53
54
55
56
57

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.
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
58
1. And as a last step, follow the [example tutorials](#examples) which will
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
59
   guide you step by step to set up the infrastructure and make use of
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
60
   Review Apps.
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
61
62
63

## Configuration

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
64
65
66
The configuration of Review apps depends on your technology stack and your
infrastructure. Read the [dynamic environments] documentation to understand
how to define and create them.
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
67
68
69

## Creating and destroying Review Apps

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
70
71
72
The creation and destruction of a Review App is defined in `.gitlab-ci.yml`
at a job level under the `environment` keyword.

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
73
74
75
76
77
78
79
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.
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
80
81
1. [Install][install-runner] and [configure][conf-runner] a Runner that does
   the deployment.
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
82
1. Set up a job in `.gitlab-ci.yml` that uses the predefined
Z.J. van de Weg's avatar
Z.J. van de Weg включено в состав коммита
83
   [predefined CI environment variable][variables] `${CI_COMMIT_REF_NAME}` to
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
84
   create dynamic environments and restrict it to run only on branches.
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
85
1. Optionally set a job that [manually stops][manual-env] the Review Apps.
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
86
87
88
89
90
91
92
93
94

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.

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
95
## Limitations
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
96

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
97
Check the [environments limitations](../environments.md#limitations).
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
98

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
99
100
101
## Examples

A list of examples used with Review Apps can be found below:
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
102

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
103
104
- [Use with NGINX][app-nginx] - Use NGINX and the shell executor of GitLab Runner
  to deploy a simple HTML website.
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
105

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
106
And below is a soon to be added examples list:
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
107

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
108
109
110
- Use with Amazon S3
- Use on Heroku with dpl
- Use with OpenShift/kubernetes
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
111

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
112
[app-nginx]: https://gitlab.com/gitlab-examples/review-apps-nginx
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
113
[ce-21971]: https://gitlab.com/gitlab-org/gitlab-ce/issues/21971
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
114
[dynamic environments]: ../environments.md#dynamic-environments
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
115
116
[environments]: ../environments.md
[fourchette]: https://github.com/rainforestapp/fourchette
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
117
118
119
120
121
[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
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
122
123
124
[install-runner]: https://docs.gitlab.com/runner/install/
[conf-runner]: https://docs.gitlab.com/runner/commands/
[manual-env]: ../environments.md#stopping-an-environment