- How Review Apps work
- Configuring Review Apps
- Review Apps auto-stop
- Review Apps examples
- Route Maps
- Visual Reviews
Review Apps
Review Apps is a collaboration tool that assists with providing an environment to showcase product changes.
Review Apps:
- Provide an automatic live preview of changes made in a feature branch by spinning up a dynamic environment for your merge requests.
- Allow designers and product managers to see your changes without needing to check out your branch and run your changes in a sandbox environment.
- Are fully integrated with the GitLab DevOps LifeCycle.
- Allow you to deploy your changes wherever you want.
In the previous example:
- A Review App is built every time a commit is pushed to
topic branch
. - The reviewer fails two reviews before passing the third review.
- After the review passes,
topic branch
is merged into the default branch, where it’s deployed to staging. - After its approval in staging, the changes that were merged into the default branch are deployed to production.
How Review Apps work
A Review App is a mapping of a branch with an environment. Access to the Review App is made available as a link on the merge request relevant to the branch.
The following is an example of a merge request with an environment set dynamically.
In this example, a branch was:
- Successfully built.
- Deployed under a dynamic environment that can be reached by selecting View app.
After adding Review Apps to your workflow, you follow the branched Git flow. That is:
- Push a branch and let the runner deploy the Review App based on the
script
definition of the dynamic environment job. - Wait for the runner to build and deploy your web application.
- To view the changes live, select the link in the merge request related to the branch.
Configuring Review Apps
Review Apps are built on dynamic environments, which allow you to dynamically create a new environment for each branch.
The process of configuring Review Apps is as follows:
- Set up the infrastructure to host and deploy the Review Apps (check the examples below).
- Install and configure a runner to do deployment.
- Set up a job in
.gitlab-ci.yml
that uses the predefined CI/CD variable${CI_COMMIT_REF_SLUG}
to create dynamic environments and restrict it to run only on branches. Alternatively, you can get a YML template for this job by enabling review apps for your project. - Optionally, set a job that manually stops the Review Apps.
Enable Review Apps button
When configuring Review Apps for a project, you add a new job to the Prerequisite:
To use the Review Apps template:
Copy the provided code snippet and paste it into your
You can edit this template as needed.
See how to configure Review Apps environments to expire and auto-stop
after a given period of time.
The following are example projects that demonstrate Review App configuration:
Other examples of Review Apps:
Route Maps allows you to go directly from source files
to public pages on the environment defined for
Review Apps.
Once set up, the review app link in the merge request
widget can take you directly to the pages changed, making it easier
and faster to preview proposed modifications.
Configuring Route Maps involves telling GitLab how the paths of files
in your repository map to paths of pages on your website using a Route Map.
Once set, GitLab displays View on … buttons, which take you
to the pages changed directly from merge requests.
To set up a route map, add a file inside the repository at The following is an example of a route map for ,
a static site generator (SSG) used to build the ,
deployed from its :
Mappings are defined as entries in the root YAML array, and are identified by a The public path for a source path is determined by finding the first
In the example above, the fact that mappings are evaluated in order
of their definition is used to ensure that After you have the route mapping set up, it takes effect in the following locations:
In the diff for a comparison or commit.
In the blob file view.
With Visual Reviews, members of any team (Product, Design, Quality, and so on) can provide feedback comments through a form in your review apps. The comments are added to the merge request that triggered the review app.
After Visual Reviews has been configured for the
Review App, the Visual Reviews feedback form is overlaid on the right side of every page.
To use the feedback form to make a comment in the merge request:
To see Visual reviews in action, see the .
The feedback form is served through a script you add to pages in your Review App.
It should be added to the Ideally, you should use CI/CD variables
to replace those values at runtime when each review app is created:
For example, in a Ruby application with code hosted on in a project GitLab.com, you would need to have this script:
Then, when your app is deployed via GitLab CI/CD, those variables should get
replaced with their real values.
The visual review tools retrieve the merge request ID from the After determining the ID for the merge request to link to a visual review app, you
can supply the ID by either:
.gitlab-ci.yml
file,
as mentioned above. To facilitate this, and if you are using Kubernetes, you can select
Enable Review Apps and GitLab prompts you with a template code block that
you can copy and paste into .gitlab-ci.yml
as a starting point.
.gitlab-ci.yml
file:
Review Apps auto-stop
Review Apps examples
Route Maps
.gitlab/route-map.yml
,
which contains a YAML array that maps source
paths (in the repository) to public
paths (on the website).
Route Maps example
# Team data
- source: 'data/team.yml' # data/team.yml
public: 'team/' # team/
# Blogposts
- source: /source\/posts\/([0-9]{4})-([0-9]{2})-([0-9]{2})-(.+?)\..*/ # source/posts/2017-01-30-around-the-world-in-6-releases.html.md.erb
public: '\1/\2/\3/\4/' # 2017/01/30/around-the-world-in-6-releases/
# HTML files
- source: /source\/(.+?\.html).*/ # source/index.html.haml
public: '\1' # index.html
# Other files
- source: /source\/(.*)/ # source/images/blogimages/around-the-world-in-6-releases-cover.png
public: '\1' # images/blogimages/around-the-world-in-6-releases-cover.png
-
prefix. Within an entry, there is a hash map with two keys:
source
'
, for an exact match.
/
, for a pattern match:
^
and $
anchors are implied.
()
that can be referred to in the public
path.
/
) can, but don’t have to, be escaped as \/
.
.
) should be escaped as \.
.
public
, a string starting and ending with '
.
\N
expressions to refer to capture groups in the source
regular expression in order of their occurrence, starting with \1
.
source
expression that matches it, and returning the corresponding
public
path, replacing the \N
expressions with the values of the
()
capture groups if appropriate.
source/index.html.haml
matches /source\/(.+?\.html).*/
instead of /source\/(.*)/
,
and results in a public path of index.html
, instead of
index.html.haml
.
Visual Reviews
anonymous_visual_review_feedback
, disabled by default.
anonymous_visual_review_feedback
.Using Visual Reviews
data-require-auth
is true
, you must enter your personal access token.
Configure Review Apps for Visual Reviews
<head>
of your application and
consists of some project and merge request specific values. Here’s how it
looks for a project with code hosted in a project on GitLab.com:
<script
data-project-id='11790219'
data-merge-request-id='1'
data-mr-url='https://gitlab.com'
data-project-path='sarah/review-app-tester'
data-require-auth='true'
id='review-app-toolbar-script'
src='https://gitlab.com/assets/webpack/visual_review_toolbar.js'>
</script>
data-project-id
is the project ID, which can be found by the CI_PROJECT_ID
variable.
data-merge-request-id
is the merge request ID, which can be found by the
CI_MERGE_REQUEST_IID
variable. CI_MERGE_REQUEST_IID
is available only if
only: [merge_requests]
is used and the merge request is created.
data-mr-url
is the URL of the GitLab instance and is the same for all
review apps.
data-project-path
is the project’s path, which can be found by CI_PROJECT_PATH
.
data-require-auth
is optional for public projects but required for private and internal ones. If this is set to true
, the user is required to enter their personal access token instead of their name and email.
id
is always review-app-toolbar-script
, you don’t need to change that.
src
is the source of the review toolbar script, which resides in the
respective GitLab instance and is the same for all review apps.
<script
data-project-id="ENV['CI_PROJECT_ID']"
data-merge-request-id="ENV['CI_MERGE_REQUEST_IID']"
data-mr-url='https://gitlab.com'
data-project-path="ENV['CI_PROJECT_PATH']"
id='review-app-toolbar-script'
src='https://gitlab.com/assets/webpack/visual_review_toolbar.js'>
</script>
Determining merge request ID
data-merge-request-id
data attribute included in the script
HTML tag used to add the visual review tools
to your review app.
data-merge-request-id
of the app.
data-merge-request-id
value during the build of the app.
Authentication for Visual Reviews