summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Fletcher <mark@gitlab.com>2017-08-25 11:01:01 +0700
committerMark Fletcher <mark@gitlab.com>2017-08-30 11:24:59 +0800
commit91cca6e4943dd64d3bfe029e3da275ed1113bf47 (patch)
tree44dfc7720a1df7320c83c0911a332a27e895fa9f
parent19dfd9e9d6cf8c260dea6a339b1842fc2399729e (diff)
downloadgitlab-ce-91cca6e4943dd64d3bfe029e3da275ed1113bf47.tar.gz
Add a Build Variable to represent the triggering GitLab user's name
* Predefined variable represents the name of the GitLab user that started a build
-rw-r--r--app/models/ci/build.rb3
-rw-r--r--doc/ci/variables/README.md6
-rw-r--r--spec/models/ci/build_spec.rb7
3 files changed, 13 insertions, 3 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 4692fb5644a..ace86e5e517 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -384,7 +384,8 @@ module Ci
[
{ key: 'GITLAB_USER_ID', value: user.id.to_s, public: true },
- { key: 'GITLAB_USER_EMAIL', value: user.email, public: true }
+ { key: 'GITLAB_USER_EMAIL', value: user.email, public: true },
+ { key: 'GITLAB_USER_NAME', value: user.name, public: true }
]
end
diff --git a/doc/ci/variables/README.md b/doc/ci/variables/README.md
index 22e7f6879ed..4b48a1f1c51 100644
--- a/doc/ci/variables/README.md
+++ b/doc/ci/variables/README.md
@@ -77,6 +77,12 @@ future GitLab releases.**
| **GITLAB_CI** | all | all | Mark that job is executed in GitLab CI environment |
| **GITLAB_USER_ID** | 8.12 | all | The id of the user who started the job |
| **GITLAB_USER_EMAIL** | 8.12 | all | The email of the user who started the job |
+<<<<<<< HEAD
+| **GITLAB_USER_NAME** | 10.0 | all | The name of the user who started the job |
+=======
+| **GITLAB_USER_USERNAME** | 10.0 | all | The username of the user who started the job |
+| **GITLAB_USER_NAME** | 10.0 | all | The real name of the user who started the job |
+>>>>>>> 940c584882... fixup name
| **RESTORE_CACHE_ATTEMPTS** | 8.15 | 1.9 | Number of attempts to restore the cache running a job |
## 9.0 Renaming
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb
index 767f0ad9e65..97fce7ded74 100644
--- a/spec/models/ci/build_spec.rb
+++ b/spec/models/ci/build_spec.rb
@@ -1247,8 +1247,11 @@ describe Ci::Build do
context 'when build has user' do
let(:user_variables) do
- [{ key: 'GITLAB_USER_ID', value: user.id.to_s, public: true },
- { key: 'GITLAB_USER_EMAIL', value: user.email, public: true }]
+ [
+ { key: 'GITLAB_USER_ID', value: user.id.to_s, public: true },
+ { key: 'GITLAB_USER_EMAIL', value: user.email, public: true },
+ { key: 'GITLAB_USER_NAME', value: user.name, public: true }
+ ]
end
before do