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
Boxiang Sun
gitlab-ce
Commits
b578fbfb
Commit
b578fbfb
authored
Apr 11, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make it possible to override build variables
parent
a1363d39
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
7 deletions
+22
-7
app/models/ci/build.rb
app/models/ci/build.rb
+2
-1
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
+1
-1
spec/models/build_spec.rb
spec/models/build_spec.rb
+19
-5
No files found.
app/models/ci/build.rb
View file @
b578fbfb
...
...
@@ -147,7 +147,8 @@ module Ci
end
def
variables
predefined_variables
+
yaml_variables
+
project_variables
+
trigger_variables
(
predefined_variables
+
yaml_variables
+
project_variables
+
trigger_variables
)
.
reverse
.
uniq
{
|
var
|
var
[
:key
]
}.
reverse
end
def
merge_request
...
...
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
View file @
b578fbfb
...
...
@@ -364,7 +364,7 @@ module Ci
end
context
'when job variables are defined'
do
let
(
:job_variables
)
{
{
KEY1
:
'value1'
,
SOME_KEY_2
:
'value2'
}
}
let
(
:job_variables
)
{
{
KEY1
:
'value1'
,
SOME_KEY_2
:
'value2'
}
}
let
(
:yaml_config
)
do
YAML
.
dump
(
{
before_script:
[
'pwd'
],
...
...
spec/models/build_spec.rb
View file @
b578fbfb
...
...
@@ -240,17 +240,31 @@ describe Ci::Build, models: true do
end
context
'when job variables are defined'
do
def
result_variables
job_variables
.
map
do
|
key
,
value
|
{
key:
key
,
value:
value
,
public:
true
}
end
end
before
{
build
.
update_attribute
(
:options
,
variables:
job_variables
)
}
context
'when job variables are unique'
do
let
(
:job_variables
)
{
{
KEY1
:
'value1'
,
KEY2
:
'value2'
}
}
let
(
:resulting_variables
)
do
[{
key: :KEY1
,
value:
'value1'
,
public:
true
},
{
key: :KEY2
,
value:
'value2'
,
public:
true
}]
end
it
'includes job variables'
do
expect
(
subject
).
to
include
(
*
resulting_variables
)
expect
(
subject
).
to
include
(
*
result_variables
)
end
end
context
'when job variable has same key other variable has'
do
let
(
:job_variables
)
{
{
CI_BUILD_NAME
:
'overridden'
}
}
it
'contains job yaml variable'
do
expect
(
subject
).
to
include
(
*
result_variables
)
end
it
'contains only one variable with this key'
do
expect
(
subject
.
count
{
|
var
|
var
[
:key
]
==
:CI_BUILD_NAME
}
).
to
eq
1
end
end
end
...
...
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