diff options
author | Robert Speicher <robert@gitlab.com> | 2017-02-07 22:14:19 +0300 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2017-02-07 22:14:19 +0300 |
commit | 58eae0961ea6e2147a288cda8a56a51303bbf13b (patch) | |
tree | 0bbd873650dfc889af8df7e197397959d774d411 /doc | |
parent | d3aaa1a2a0313b7132479d4211e406fde5bc9324 (diff) | |
parent | 0fdf54ddf5894ec1057b7351140fdce4f0df0ed1 (diff) |
Merge branch 'route-map' into 'master'
Add 'View on [env]' link to blobs and individual files in diffs
See merge request !8867
Diffstat (limited to 'doc')
-rw-r--r-- | doc/ci/environments.md | 39 | ||||
-rw-r--r-- | doc/ci/img/view_on_env_blob.png | bin | 0 -> 111663 bytes | |||
-rw-r--r-- | doc/ci/img/view_on_env_mr.png | bin | 0 -> 1005195 bytes |
3 files changed, 39 insertions, 0 deletions
diff --git a/doc/ci/environments.md b/doc/ci/environments.md index 579135c2052..f00cc854b05 100644 --- a/doc/ci/environments.md +++ b/doc/ci/environments.md @@ -442,6 +442,45 @@ and/or `production`) you can see this information in the merge request itself. ![Environment URLs in merge request](img/environments_link_url_mr.png) +### Go directly from source files to public pages on the environment + +> Introduced in GitLab 8.17. + +To go one step further, we can specify a Route Map to get GitLab to show us "View on [environment URL]" buttons to go directly from a file to that file's representation on the deployed website. It will be exposed in a few places: + +| In the diff for a merge request, comparison or commit | In the file view | +| ------ | ------ | +| !["View on env" button in merge request diff](img/view_on_env_mr.png) | !["View on env" button in file view](img/view_on_env_blob.png) | + +To get this to work, you need to tell GitLab how the paths of files in your repository map to paths of pages on your website, using a Route Map. + +A Route Map is a file inside the repository at `.gitlab/route-map.yml`, which contains a YAML array that maps `source` paths (in the repository) to `public` paths (on the website). + +This is an example of a route map for [Middleman](https://middlemanapp.com) static websites like [http://about.gitlab.com](https://gitlab.com/gitlab-com/www-gitlab-com): + +```yaml +# 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 +``` + +Mappings are defined as entries in the root YAML array, and are identified by a `-` prefix. Within an entry, we have a hash map with two keys: + +- `source`: a regular expression, starting and ending with `/`. Can include capture groups denoted by `()` that can be referred to in the `public` path. Slashes (`/`) can, but don't have to be, escaped as `\/`. +- `public`: a string, starting and ending with `'`. Can include `\N` expressions to refer to capture groups in the `source` regular expression in order of their occurence, starting with `\1`. + +The public path for a source path is determined by finding the first `source` expression that matches it, and returning the corresponding `public` path, replacing the `\N` expressions with the values of the `()` capture groups. + +In the example above, the fact that mappings are evaluated in order of their definition is used to ensure that `source/index.html.haml` will match `/source\/(.+?\.html).*/` instead of `/source\/(.*)/`, and will result in a public path of `index.html`, instead of `index.html.haml`. + --- We now have a full development cycle, where our app is tested, built, deployed diff --git a/doc/ci/img/view_on_env_blob.png b/doc/ci/img/view_on_env_blob.png Binary files differnew file mode 100644 index 00000000000..f4fe99046f0 --- /dev/null +++ b/doc/ci/img/view_on_env_blob.png diff --git a/doc/ci/img/view_on_env_mr.png b/doc/ci/img/view_on_env_mr.png Binary files differnew file mode 100644 index 00000000000..47ddb40bdc1 --- /dev/null +++ b/doc/ci/img/view_on_env_mr.png |