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
5b88bd81
Commit
5b88bd81
authored
Sep 04, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move trigger_variables to presenter
parent
fa6b9aca
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
51 deletions
+49
-51
app/models/ci/build.rb
app/models/ci/build.rb
+2
-12
app/presenters/ci/build_presenter.rb
app/presenters/ci/build_presenter.rb
+11
-0
lib/gitlab/gitaly_client.rb
lib/gitlab/gitaly_client.rb
+2
-1
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+0
-38
spec/presenters/ci/build_presenter_spec.rb
spec/presenters/ci/build_presenter_spec.rb
+34
-0
No files found.
app/models/ci/build.rb
View file @
5b88bd81
...
@@ -221,24 +221,14 @@ module Ci
...
@@ -221,24 +221,14 @@ module Ci
variables
+=
user_variables
variables
+=
user_variables
variables
+=
project
.
group
.
secret_variables_for
(
ref
,
project
).
map
(
&
:to_runner_variable
)
if
project
.
group
variables
+=
project
.
group
.
secret_variables_for
(
ref
,
project
).
map
(
&
:to_runner_variable
)
if
project
.
group
variables
+=
secret_variables
(
environment:
environment
)
variables
+=
secret_variables
(
environment:
environment
)
variables
+=
trigger_variables
variables
+=
trigger_request
.
user_variables
if
trigger_request
variables
+=
pipeline
.
variables
.
map
(
&
:to_runner_variable
)
variables
+=
pipeline
.
pipeline_schedule
.
job_variables
if
pipeline
.
pipeline_schedule
variables
+=
pipeline
.
pipeline_schedule
.
job_variables
if
pipeline
.
pipeline_schedule
variables
+=
persisted_environment_variables
if
environment
variables
+=
persisted_environment_variables
if
environment
variables
variables
end
end
def
trigger_variables
return
[]
unless
trigger_request
# or pipeline.trigger?
@trigger_variables
||=
if
pipeline
.
variables
.
any?
# If it's swtiched to Ci::PipelineVariables
pipeline
.
variables
.
map
(
&
:to_runner_variable
)
else
# else it's still using trigger_request.variables
trigger_request
.
user_variables
# Deprecated
end
end
def
merge_request
def
merge_request
return
@merge_request
if
defined?
(
@merge_request
)
return
@merge_request
if
defined?
(
@merge_request
)
...
...
app/presenters/ci/build_presenter.rb
View file @
5b88bd81
...
@@ -17,5 +17,16 @@ module Ci
...
@@ -17,5 +17,16 @@ module Ci
"Job is redundant and is auto-canceled by Pipeline #
#{
auto_canceled_by_id
}
"
"Job is redundant and is auto-canceled by Pipeline #
#{
auto_canceled_by_id
}
"
end
end
end
end
def
trigger_variables
return
[]
unless
trigger_request
@trigger_variables
||=
if
pipeline
.
variables
.
any?
pipeline
.
variables
.
map
(
&
:to_runner_variable
)
else
trigger_request
.
user_variables
end
end
end
end
end
end
lib/gitlab/gitaly_client.rb
View file @
5b88bd81
...
@@ -23,7 +23,8 @@ module Gitlab
...
@@ -23,7 +23,8 @@ module Gitlab
klass
=
Gitaly
.
const_get
(
name
.
to_s
.
camelcase
.
to_sym
).
const_get
(
:Stub
)
klass
=
Gitaly
.
const_get
(
name
.
to_s
.
camelcase
.
to_sym
).
const_get
(
:Stub
)
addr
=
address
(
storage
)
addr
=
address
(
storage
)
addr
=
addr
.
sub
(
%r{^tcp://}
,
''
)
if
URI
(
addr
).
scheme
==
'tcp'
addr
=
addr
.
sub
(
%r{^tcp://}
,
''
)
if
URI
(
addr
).
scheme
==
'tcp'
klass
.
new
(
addr
,
:this_channel_is_insecure
)
timeout
=
10
if
Rails
.
env
.
test?
klass
.
new
(
addr
,
:this_channel_is_insecure
,
timeout:
timeout
)
end
end
end
end
end
end
...
...
spec/models/ci/build_spec.rb
View file @
5b88bd81
...
@@ -1690,44 +1690,6 @@ describe Ci::Build do
...
@@ -1690,44 +1690,6 @@ describe Ci::Build do
end
end
end
end
describe
'#trigger_variables'
do
let
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
trigger_request:
trigger_request
)
}
let
(
:trigger
)
{
create
(
:ci_trigger
,
project:
project
)
}
let
(
:trigger_request
)
{
create
(
:ci_trigger_request
,
pipeline:
pipeline
,
trigger:
trigger
)
}
subject
{
build
.
trigger_variables
}
it
{
is_expected
.
to
eq
(
true
)
}
context
'when variable is stored in ci_pipeline_variables'
do
let!
(
:pipeline_variable
)
{
create
(
:ci_pipeline_variable
,
pipeline:
pipeline
)
}
context
'when pipeline is triggered by trigger API'
do
it
'returns variables'
do
is_expected
.
to
eq
([
pipeline_variable
.
to_runner_variable
])
end
end
context
'when pipeline is not triggered by trigger API'
do
let
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
it
'does not return variables'
do
is_expected
.
to
eq
([])
end
end
end
context
'when variable is stored in ci_trigger_requests.variables'
do
before
do
trigger_request
.
update_attribute
(
:variables
,
{
'TRIGGER_KEY_1'
=>
'TRIGGER_VALUE_1'
}
)
end
it
'returns variables'
do
is_expected
.
to
eq
(
trigger_request
.
user_variables
)
end
end
end
describe
'state transition: any => [:pending]'
do
describe
'state transition: any => [:pending]'
do
let
(
:build
)
{
create
(
:ci_build
,
:created
)
}
let
(
:build
)
{
create
(
:ci_build
,
:created
)
}
...
...
spec/presenters/ci/build_presenter_spec.rb
View file @
5b88bd81
...
@@ -100,4 +100,38 @@ describe Ci::BuildPresenter do
...
@@ -100,4 +100,38 @@ describe Ci::BuildPresenter do
end
end
end
end
end
end
describe
'#trigger_variables'
do
let
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
trigger_request:
trigger_request
)
}
let
(
:trigger
)
{
create
(
:ci_trigger
,
project:
project
)
}
let
(
:trigger_request
)
{
create
(
:ci_trigger_request
,
pipeline:
pipeline
,
trigger:
trigger
)
}
context
'when variable is stored in ci_pipeline_variables'
do
let!
(
:pipeline_variable
)
{
create
(
:ci_pipeline_variable
,
pipeline:
pipeline
)
}
context
'when pipeline is triggered by trigger API'
do
it
'returns variables'
do
expect
(
presenter
.
trigger_variables
).
to
eq
([
pipeline_variable
.
to_runner_variable
])
end
end
context
'when pipeline is not triggered by trigger API'
do
let
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
it
'does not return variables'
do
expect
(
presenter
.
trigger_variables
).
to
eq
([])
end
end
end
context
'when variable is stored in ci_trigger_requests.variables'
do
before
do
trigger_request
.
update_attribute
(
:variables
,
{
'TRIGGER_KEY_1'
=>
'TRIGGER_VALUE_1'
}
)
end
it
'returns variables'
do
expect
(
presenter
.
trigger_variables
).
to
eq
(
trigger_request
.
user_variables
)
end
end
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