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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
beba8485
Commit
beba8485
authored
Jun 14, 2017
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure that we only call secret_variables_for once
parent
de22236c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
11 deletions
+26
-11
app/models/ci/build.rb
app/models/ci/build.rb
+6
-6
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+20
-5
No files found.
app/models/ci/build.rb
View file @
beba8485
...
...
@@ -393,13 +393,13 @@ module Ci
end
def
secret_variables
(
with_environment:
true
)
variables
=
project
.
secret_variables_for
(
ref:
ref
)
if
with_environment
variables
.
concat
(
variables
=
if
with_environment
project
.
secret_variables_for
(
ref:
ref
,
environment:
persisted_environment
))
end
ref:
ref
,
environment:
persisted_environment
)
else
project
.
secret_variables_for
(
ref:
ref
)
end
variables
.
map
(
&
:to_runner_variable
)
end
...
...
spec/models/ci/build_spec.rb
View file @
beba8485
...
...
@@ -1388,6 +1388,24 @@ describe Ci::Build, :models do
context
'when the ref is not protected'
do
it
{
is_expected
.
not_to
include
(
protected_variable
)
}
end
# EE
context
'when environment specific variable is defined'
do
let
(
:environment_varialbe
)
do
{
key:
'ENV_KEY'
,
value:
'environment'
,
public:
false
}
end
before
do
build
.
update
(
environment:
'staging'
)
create
(
:environment
,
name:
'staging'
,
project:
build
.
project
)
create
(
:ci_variable
,
environment_varialbe
.
slice
(
:key
,
:value
)
.
merge
(
project:
project
,
scope:
'stag*'
))
end
it
{
is_expected
.
to
include
(
environment_varialbe
)
}
end
end
context
'when build is for triggers'
do
...
...
@@ -1520,13 +1538,10 @@ describe Ci::Build, :models do
allow
(
pipeline
).
to
receive
(
:predefined_variables
)
{
[
pipeline_pre_var
]
}
allow
(
build
).
to
receive
(
:yaml_variables
)
{
[
build_yaml_var
]
}
allow
(
project
).
to
receive
(
:secret_variables_for
).
with
(
ref:
'master'
)
do
[
create
(
:ci_variable
,
key:
'secret'
,
value:
'value'
)]
end
allow
(
project
).
to
receive
(
:secret_variables_for
)
.
with
(
ref:
'master'
,
environment:
nil
)
do
[
create
(
:ci_variable
,
key:
'env'
,
value:
'value'
)]
[
create
(
:ci_variable
,
key:
'secret'
,
value:
'value'
),
create
(
:ci_variable
,
key:
'env'
,
value:
'value'
)]
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