Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
0f73dd34
Commit
0f73dd34
authored
Sep 05, 2016
by
Sergey Gnuskov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add information about user and manual build start to runner as variables
parent
4c833a1d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
0 deletions
+46
-0
CHANGELOG
CHANGELOG
+1
-0
app/models/ci/build.rb
app/models/ci/build.rb
+11
-0
doc/ci/variables/README.md
doc/ci/variables/README.md
+6
-0
spec/models/build_spec.rb
spec/models/build_spec.rb
+28
-0
No files found.
CHANGELOG
View file @
0f73dd34
...
@@ -99,6 +99,7 @@ v 8.12.0 (unreleased)
...
@@ -99,6 +99,7 @@ v 8.12.0 (unreleased)
- Fix hover leading space bug in pipeline graph !5980
- Fix hover leading space bug in pipeline graph !5980
- User can edit closed MR with deleted fork (Katarzyna Kobierska Ula Budziszewska) !5496
- User can edit closed MR with deleted fork (Katarzyna Kobierska Ula Budziszewska) !5496
- Fix repository page ui issues
- Fix repository page ui issues
- Add information about user and manual build start to runner as variables !6201 (Sergey Gnuskov)
- Fixed invisible scroll controls on build page on iPhone
- Fixed invisible scroll controls on build page on iPhone
- Fix error on raw build trace download for old builds stored in database !4822
- Fix error on raw build trace download for old builds stored in database !4822
- Refactor the triggers page and documentation !6217
- Refactor the triggers page and documentation !6217
...
...
app/models/ci/build.rb
View file @
0f73dd34
...
@@ -148,6 +148,7 @@ module Ci
...
@@ -148,6 +148,7 @@ module Ci
variables
+=
runner
.
predefined_variables
if
runner
variables
+=
runner
.
predefined_variables
if
runner
variables
+=
project
.
container_registry_variables
variables
+=
project
.
container_registry_variables
variables
+=
yaml_variables
variables
+=
yaml_variables
variables
+=
user_variables
variables
+=
project
.
secret_variables
variables
+=
project
.
secret_variables
variables
+=
trigger_request
.
user_variables
if
trigger_request
variables
+=
trigger_request
.
user_variables
if
trigger_request
variables
variables
...
@@ -434,6 +435,15 @@ module Ci
...
@@ -434,6 +435,15 @@ module Ci
read_attribute
(
:yaml_variables
)
||
build_attributes_from_config
[
:yaml_variables
]
||
[]
read_attribute
(
:yaml_variables
)
||
build_attributes_from_config
[
:yaml_variables
]
||
[]
end
end
def
user_variables
return
[]
if
user
.
blank?
[
{
key:
'GITLAB_USER_ID'
,
value:
user
.
id
.
to_s
,
public:
true
},
{
key:
'GITLAB_USER_EMAIL'
,
value:
user
.
email
,
public:
true
}
]
end
private
private
def
update_artifacts_size
def
update_artifacts_size
...
@@ -469,6 +479,7 @@ module Ci
...
@@ -469,6 +479,7 @@ module Ci
]
]
variables
<<
{
key:
'CI_BUILD_TAG'
,
value:
ref
,
public:
true
}
if
tag?
variables
<<
{
key:
'CI_BUILD_TAG'
,
value:
ref
,
public:
true
}
if
tag?
variables
<<
{
key:
'CI_BUILD_TRIGGERED'
,
value:
'true'
,
public:
true
}
if
trigger_request
variables
<<
{
key:
'CI_BUILD_TRIGGERED'
,
value:
'true'
,
public:
true
}
if
trigger_request
variables
<<
{
key:
'CI_BUILD_MANUAL'
,
value:
'true'
,
public:
true
}
if
manual?
variables
variables
end
end
...
...
doc/ci/variables/README.md
View file @
0f73dd34
...
@@ -34,6 +34,7 @@ The `API_TOKEN` will take the Secure Variable value: `SECURE`.
...
@@ -34,6 +34,7 @@ The `API_TOKEN` will take the Secure Variable value: `SECURE`.
|
**CI_BUILD_REF_NAME**
| all | all | The branch or tag name for which project is built |
|
**CI_BUILD_REF_NAME**
| all | all | The branch or tag name for which project is built |
|
**CI_BUILD_REPO**
| all | all | The URL to clone the Git repository |
|
**CI_BUILD_REPO**
| all | all | The URL to clone the Git repository |
|
**CI_BUILD_TRIGGERED**
| all | 0.5 | The flag to indicate that build was [triggered] |
|
**CI_BUILD_TRIGGERED**
| all | 0.5 | The flag to indicate that build was [triggered] |
|
**CI_BUILD_MANUAL**
| 8.12 | all | The flag to indicate that build was manually started |
|
**CI_BUILD_TOKEN**
| all | 1.2 | Token used for authenticating with the GitLab Container Registry |
|
**CI_BUILD_TOKEN**
| all | 1.2 | Token used for authenticating with the GitLab Container Registry |
|
**CI_PIPELINE_ID**
| 8.10 | 0.5 | The unique id of the current pipeline that GitLab CI uses internally |
|
**CI_PIPELINE_ID**
| 8.10 | 0.5 | The unique id of the current pipeline that GitLab CI uses internally |
|
**CI_PROJECT_ID**
| all | all | The unique id of the current project that GitLab CI uses internally |
|
**CI_PROJECT_ID**
| all | all | The unique id of the current project that GitLab CI uses internally |
...
@@ -47,6 +48,8 @@ The `API_TOKEN` will take the Secure Variable value: `SECURE`.
...
@@ -47,6 +48,8 @@ The `API_TOKEN` will take the Secure Variable value: `SECURE`.
|
**CI_RUNNER_ID**
| 8.10 | 0.5 | The unique id of runner being used |
|
**CI_RUNNER_ID**
| 8.10 | 0.5 | The unique id of runner being used |
|
**CI_RUNNER_DESCRIPTION**
| 8.10 | 0.5 | The description of the runner as saved in GitLab |
|
**CI_RUNNER_DESCRIPTION**
| 8.10 | 0.5 | The description of the runner as saved in GitLab |
|
**CI_RUNNER_TAGS**
| 8.10 | 0.5 | The defined runner tags |
|
**CI_RUNNER_TAGS**
| 8.10 | 0.5 | The defined runner tags |
|
**GITLAB_USER_ID**
| 8.12 | all | The id of the user who started the build |
|
**GITLAB_USER_EMAIL**
| 8.12 | all | The email of the user who started the build |
**Some of the variables are only available when using runner with at least defined version.**
**Some of the variables are only available when using runner with at least defined version.**
...
@@ -60,6 +63,7 @@ export CI_BUILD_REPO="https://gitab-ci-token:abcde-1234ABCD5678ef@gitlab.com/git
...
@@ -60,6 +63,7 @@ export CI_BUILD_REPO="https://gitab-ci-token:abcde-1234ABCD5678ef@gitlab.com/git
export
CI_BUILD_TAG
=
"1.0.0"
export
CI_BUILD_TAG
=
"1.0.0"
export
CI_BUILD_NAME
=
"spec:other"
export
CI_BUILD_NAME
=
"spec:other"
export
CI_BUILD_STAGE
=
"test"
export
CI_BUILD_STAGE
=
"test"
export
CI_BUILD_MANUAL
=
"true"
export
CI_BUILD_TRIGGERED
=
"true"
export
CI_BUILD_TRIGGERED
=
"true"
export
CI_BUILD_TOKEN
=
"abcde-1234ABCD5678ef"
export
CI_BUILD_TOKEN
=
"abcde-1234ABCD5678ef"
export
CI_PIPELINE_ID
=
"1000"
export
CI_PIPELINE_ID
=
"1000"
...
@@ -78,6 +82,8 @@ export CI_SERVER="yes"
...
@@ -78,6 +82,8 @@ export CI_SERVER="yes"
export
CI_SERVER_NAME
=
"GitLab"
export
CI_SERVER_NAME
=
"GitLab"
export
CI_SERVER_REVISION
=
"70606bf"
export
CI_SERVER_REVISION
=
"70606bf"
export
CI_SERVER_VERSION
=
"8.9.0"
export
CI_SERVER_VERSION
=
"8.9.0"
export
GITLAB_USER_ID
=
"42"
export
GITLAB_USER_EMAIL
=
"alexzander@sporer.com"
```
```
### YAML-defined variables
### YAML-defined variables
...
...
spec/models/build_spec.rb
View file @
0f73dd34
...
@@ -231,6 +231,34 @@ describe Ci::Build, models: true do
...
@@ -231,6 +231,34 @@ describe Ci::Build, models: true do
it
{
is_expected
.
to
eq
(
predefined_variables
)
}
it
{
is_expected
.
to
eq
(
predefined_variables
)
}
end
end
context
'when build has user'
do
let
(
:user
)
{
create
(
:user
,
username:
'starter'
)
}
let
(
:user_variables
)
do
[
{
key:
'GITLAB_USER_ID'
,
value:
user
.
id
.
to_s
,
public:
true
},
{
key:
'GITLAB_USER_EMAIL'
,
value:
user
.
email
,
public:
true
}
]
end
before
do
build
.
update_attributes
(
user:
user
)
end
it
{
user_variables
.
each
{
|
v
|
is_expected
.
to
include
(
v
)
}
}
end
context
'when build started manually'
do
before
do
build
.
update_attributes
(
when: :manual
)
end
let
(
:manual_variable
)
do
{
key:
'CI_BUILD_MANUAL'
,
value:
'true'
,
public:
true
}
end
it
{
is_expected
.
to
include
(
manual_variable
)
}
end
context
'when build is for tag'
do
context
'when build is for tag'
do
let
(
:tag_variable
)
do
let
(
:tag_variable
)
do
{
key:
'CI_BUILD_TAG'
,
value:
'master'
,
public:
true
}
{
key:
'CI_BUILD_TAG'
,
value:
'master'
,
public:
true
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment