Commit 29b6d4d5 authored by Achilleas Pipinellis's avatar Achilleas Pipinellis Committed by Alejandro Rodríguez

Merge branch 'docs/review-apps' into 'master'

Add documentation for Review Apps

## What does this MR do?

Add docs for review apps.

## What are the relevant issue numbers?

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/23484

See merge request !6982
parent 03b10e58
## GitLab CI Documentation
# GitLab CI Documentation
### CI User documentation
## CI User documentation
- [Get started with GitLab CI](quick_start/README.md)
- [CI examples for various languages](examples/README.md)
......@@ -20,4 +20,8 @@
- [API](../api/ci/README.md)
- [CI services (linked docker containers)](services/README.md)
- [CI/CD pipelines settings](../user/project/pipelines/settings.md)
- [**New CI build permissions model**](../user/project/new_ci_build_permissions_model.md) Read about what changed in GitLab 8.12 and how that affects your builds. There's a new way to access your Git submodules and LFS objects in builds.
- [Review Apps](review_apps/index.md)
## Breaking changes
- [New CI build permissions model](../user/project/new_ci_build_permissions_model.md) Read about what changed in GitLab 8.12 and how that affects your builds. There's a new way to access your Git submodules and LFS objects in builds.
......@@ -479,13 +479,22 @@ fetch line:
fetch = +refs/environments/*:refs/remotes/origin/environments/*
```
## Limitations
- You are limited to use only the [CI predefined variables][variables] in the
`environment: name`. Any variables defined inside `script` will not work.
- If the branch name contains special characters and you use the
`$CI_BUILD_REF_NAME` variable to dynamically create environments, there might
be complications during deployment. Follow the [issue 22849][ce-22849] for
more information.
## Further reading
Below are some links you may find interesting:
- [The `.gitlab-ci.yml` definition of environments](yaml/README.md#environment)
- [A blog post on Deployments & Environments](https://about.gitlab.com/2016/08/26/ci-deployment-and-environments/)
- [Review Apps](review_apps.md) Expand dynamic environments to deploy your code for every branch
- [Review Apps - Use dynamic environments to deploy your code for every branch](review_apps/index.md)
[Pipelines]: pipelines.md
[jobs]: yaml/README.md#jobs
......
# Getting started with Review Apps
>
- [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].
The base of Review Apps is the [dynamic environments] which allow you to create
a new environment (dynamically) for each one of your branches.
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.
They mostly make sense to be used with web applications, but you can use them
any way you'd like.
## Overview
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.
The details of the Review Apps implementation depend widely on your real
technology stack and on your deployment process. The simplest case it to
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
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.
1. And as a last step, follow the [example tutorials](#examples) which will
guide you step by step to set up the infrastructure and make use of
Review Apps.
## Configuration
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.
## Creating and destroying Review Apps
The creation and destruction of a Review App is defined in `.gitlab-ci.yml`
at a job level under the `environment` keyword.
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][install-runner] and [configure][conf-runner] 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 [manually stops][manual-env] 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.
## Limitations
Check the [environments limitations](../environments.md#limitations).
## Examples
A list of examples used with Review Apps can be found below:
- [Use with NGINX][app-nginx] - Use NGINX and the shell executor of GitLab Runner
to deploy a simple HTML website.
And below is a soon to be added examples list:
- Use with Amazon S3
- Use on Heroku with dpl
- Use with OpenShift/kubernetes
[app-nginx]: https://gitlab.com/gitlab-examples/review-apps-nginx
[ce-21971]: https://gitlab.com/gitlab-org/gitlab-ce/issues/21971
[dynamic environments]: ../environments.md#dynamic-environments
[environments]: ../environments.md
[fourchette]: https://github.com/rainforestapp/fourchette
[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
[install-runner]: https://docs.gitlab.com/runner/install/
[conf-runner]: https://docs.gitlab.com/runner/commands/
[manual-env]: ../environments.md#stopping-an-environment
......@@ -541,6 +541,8 @@ same manual action multiple times.
An example usage of manual actions is deployment to production.
Read more at the [environments documentation][env-manual].
### environment
> Introduced in GitLab 8.9.
......@@ -687,6 +689,13 @@ The `stop_review_app` job is **required** to have the following keywords defined
These parameters can use any of the defined [CI variables](#variables)
(including predefined, secure variables and `.gitlab-ci.yml` variables).
>**Note:**
Be aware than if the branch name contains special characters and you use the
`$CI_BUILD_REF_NAME` variable to dynamically create environments, there might
be complications during deployment. Follow the
[issue 22849](https://gitlab.com/gitlab-org/gitlab-ce/issues/22849) for more
information.
For example:
```
......@@ -1216,6 +1225,7 @@ capitalization, the commit will be created but the builds will be skipped.
Visit the [examples README][examples] to see a list of examples using GitLab
CI with various languages.
[env-manual]: ../environments.md#manually-deploying-to-environments
[examples]: ../examples/README.md
[ce-6323]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6323
[environment]: ../environments.md
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment