Skip to content
Next
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
GitLab FOSS
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Security & Compliance
Security & Compliance
Dependency List
Packages
Packages
Container Registry
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
GitLab.org
GitLab FOSS
Commits
d614c431
Commit
d614c431
authored
Sep 01, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix trigger_request.variables
parent
cff104ec
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
7 deletions
+6
-7
lib/api/v3/triggers.rb
lib/api/v3/triggers.rb
+2
-4
spec/models/ci/trigger_request_spec.rb
spec/models/ci/trigger_request_spec.rb
+2
-2
spec/requests/api/v3/triggers_spec.rb
spec/requests/api/v3/triggers_spec.rb
+2
-1
No files found.
lib/api/v3/triggers.rb
View file @
d614c431
...
...
@@ -32,15 +32,13 @@ module API
render_api_error!
(
result
[
:message
],
result
[
:http_status
])
else
pipeline
=
result
[
:pipeline
]
trigger_request
=
pipeline
.
trigger_request
trigger_request
=
Ci
::
TriggerRequest
.
find_by
(
commit_id:
pipeline
.
id
)
# We switched to Ci::PipelineVariable from Ci::TriggerRequest.variables.
# Ci::TriggerRequest doesn't save variables anymore.
# Here is copying Ci::PipelineVariable to Ci::TriggerRequest.variables for presenting the variables.
# The same endpoint in v4 API pressents Pipeline instead of TriggerRequest, so it doesn't need such a process.
pipeline
.
variables
.
each
do
|
variable
|
trigger_request
.
variables
<<
{
key:
variable
.
key
,
value:
variable
.
value
}
end
trigger_request
.
variables
=
params
[
:variables
]
present
trigger_request
,
with:
::
API
::
V3
::
Entities
::
TriggerRequest
end
...
...
spec/models/ci/trigger_request_spec.rb
View file @
d614c431
...
...
@@ -5,13 +5,13 @@ describe Ci::TriggerRequest do
it
'be invalid if saving a variable'
do
trigger
=
build
(
:ci_trigger_request
,
variables:
{
TRIGGER_KEY_1
:
'TRIGGER_VALUE_1'
}
)
expect
(
trigger
.
valid?
).
to
be_falsey
expect
(
trigger
).
not_to
be_valid
end
it
'be valid if not saving a variable'
do
trigger
=
build
(
:ci_trigger_request
)
expect
(
trigger
.
valid?
).
to
be_truthy
expect
(
trigger
).
to
be_valid
end
end
end
spec/requests/api/v3/triggers_spec.rb
View file @
d614c431
...
...
@@ -80,7 +80,8 @@ describe API::V3::Triggers do
post
v3_api
(
"/projects/
#{
project
.
id
}
/trigger/builds"
),
options
.
merge
(
variables:
variables
,
ref:
'master'
)
expect
(
response
).
to
have_http_status
(
201
)
pipeline
.
builds
.
reload
expect
(
pipeline
.
builds
.
first
.
trigger_request
.
variables
).
to
eq
(
variables
)
expect
(
pipeline
.
variables
.
map
{
|
v
|
{
v
.
key
=>
v
.
value
}
}.
first
).
to
eq
(
variables
)
expect
(
json_response
[
'variables'
]).
to
eq
(
variables
)
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