gitlab-org--gitlab-foss/app/models/ci
Kamil Trzciński 51830b6659 Merge branch '22849-ci-build-ref-slug' into 'master'
Introduce $CI_BUILD_REF_SLUG

## What does this MR do?

Adds `$CI_BUILD_REF_SLUG` to the variables exposed to the runner. This is based on `$CI_BUILD_REF_NAME` but lowercased, shortened to 63 bytes maximum, and with characters invalid in URLs and domain names replaced with `-`. 

## Are there points in the code the reviewer needs to double check?

Slugs don't have a uniqueness guarantee. !7983 introduces an environment name slug which *is* unique, so I'm not as exercised about this as I was.

Should the slug be published in the API? It's available through the `variables` endpoint, but perhaps it should be part of `GET /project/:id/builds` ?

I've called it `ref_slug` rather than just `slug` as there are number of possibilities for slugification in a build (unlike an environment, where only the name makes sense to slugify).

## Why was this MR needed?

`$CI_BUILD_REF_NAME` is not suited for URLs and domain names, given the list of valid characters in a git ref. 

## Screenshots (if relevant)

## Does this MR meet the acceptance criteria?

- [x] [Changelog entry](https://docs.gitlab.com/ce/development/changelog.html) added
- [X] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)
- [ ] API support added
- Tests
  - [X] Added for this feature/bug
  - [x] All builds are passing
- [X] Conform by the [merge request performance guides](http://docs.gitlab.com/ce/development/merge_request_performance_guidelines.html)
- [X] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [X] Branch has no merge conflicts with `master` (if it does - rebase it please)
- [X] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)

## What are the relevant issue numbers?

Closes #22849

See merge request !8072
2016-12-15 11:08:27 +00:00
..
build.rb Merge branch '22849-ci-build-ref-slug' into 'master' 2016-12-15 11:08:27 +00:00
pipeline.rb Improve readability in methods for detailed status 2016-12-13 13:24:25 +01:00
runner.rb Remove redundant class_name and foreign_key overrides 2016-10-24 22:29:48 +02:00
runner_project.rb Remove redundant class_name and foreign_key overrides 2016-10-24 22:29:48 +02:00
stage.rb Improve readability in methods for detailed status 2016-12-13 13:24:25 +01:00
trigger.rb Remove redundant class_name and foreign_key overrides 2016-10-24 22:29:48 +02:00
trigger_request.rb Remove redundant class_name and foreign_key overrides 2016-10-24 22:29:48 +02:00
variable.rb Use :maximum instead of :within for length validators with a 0..N range 2016-12-06 10:23:17 +01:00