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
Léo-Paul Géneau
gitlab-ce
Commits
acc74978
Commit
acc74978
authored
Aug 26, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert autheticate! in Trigger API
parent
75130a41
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
22 additions
and
23 deletions
+22
-23
lib/api/triggers.rb
lib/api/triggers.rb
+4
-4
lib/api/v3/triggers.rb
lib/api/v3/triggers.rb
+4
-4
spec/factories/ci/builds.rb
spec/factories/ci/builds.rb
+1
-1
spec/factories/ci/trigger_requests.rb
spec/factories/ci/trigger_requests.rb
+8
-9
spec/features/projects/jobs_spec.rb
spec/features/projects/jobs_spec.rb
+1
-1
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+1
-1
spec/requests/api/runner_spec.rb
spec/requests/api/runner_spec.rb
+1
-1
spec/requests/api/v3/triggers_spec.rb
spec/requests/api/v3/triggers_spec.rb
+1
-1
spec/views/projects/jobs/show.html.haml_spec.rb
spec/views/projects/jobs/show.html.haml_spec.rb
+1
-1
No files found.
lib/api/triggers.rb
View file @
acc74978
...
@@ -15,16 +15,16 @@ module API
...
@@ -15,16 +15,16 @@ module API
optional
:variables
,
type:
Hash
,
desc:
'The list of variables to be injected into build'
optional
:variables
,
type:
Hash
,
desc:
'The list of variables to be injected into build'
end
end
post
":id/(ref/:ref/)trigger/pipeline"
,
requirements:
{
ref:
/.+/
}
do
post
":id/(ref/:ref/)trigger/pipeline"
,
requirements:
{
ref:
/.+/
}
do
authenticate!
authorize!
:admin_build
,
user_project
# validate variables
# validate variables
params
[
:variables
]
=
params
[
:variables
].
to_h
params
[
:variables
]
=
params
[
:variables
].
to_h
unless
params
[
:variables
].
all?
{
|
key
,
value
|
key
.
is_a?
(
String
)
&&
value
.
is_a?
(
String
)
}
unless
params
[
:variables
].
all?
{
|
key
,
value
|
key
.
is_a?
(
String
)
&&
value
.
is_a?
(
String
)
}
render_api_error!
(
'variables needs to be a map of key-valued strings'
,
400
)
render_api_error!
(
'variables needs to be a map of key-valued strings'
,
400
)
end
end
result
=
Ci
::
PipelineTriggerService
.
new
(
user_project
,
nil
,
params
).
execute
project
=
find_project
(
params
[
:id
])
not_found!
unless
project
result
=
Ci
::
PipelineTriggerService
.
new
(
project
,
nil
,
params
).
execute
not_found!
unless
result
not_found!
unless
result
if
result
[
:http_status
]
if
result
[
:http_status
]
...
...
lib/api/v3/triggers.rb
View file @
acc74978
...
@@ -16,16 +16,16 @@ module API
...
@@ -16,16 +16,16 @@ module API
optional
:variables
,
type:
Hash
,
desc:
'The list of variables to be injected into build'
optional
:variables
,
type:
Hash
,
desc:
'The list of variables to be injected into build'
end
end
post
":id/(ref/:ref/)trigger/builds"
,
requirements:
{
ref:
/.+/
}
do
post
":id/(ref/:ref/)trigger/builds"
,
requirements:
{
ref:
/.+/
}
do
authenticate!
authorize!
:admin_build
,
user_project
# validate variables
# validate variables
params
[
:variables
]
=
params
[
:variables
].
to_h
params
[
:variables
]
=
params
[
:variables
].
to_h
unless
params
[
:variables
].
all?
{
|
key
,
value
|
key
.
is_a?
(
String
)
&&
value
.
is_a?
(
String
)
}
unless
params
[
:variables
].
all?
{
|
key
,
value
|
key
.
is_a?
(
String
)
&&
value
.
is_a?
(
String
)
}
render_api_error!
(
'variables needs to be a map of key-valued strings'
,
400
)
render_api_error!
(
'variables needs to be a map of key-valued strings'
,
400
)
end
end
result
=
Ci
::
PipelineTriggerService
.
new
(
user_project
,
nil
,
params
).
execute
project
=
find_project
(
params
[
:id
])
not_found!
unless
project
result
=
Ci
::
PipelineTriggerService
.
new
(
project
,
nil
,
params
).
execute
not_found!
unless
result
not_found!
unless
result
if
result
[
:http_status
]
if
result
[
:http_status
]
...
...
spec/factories/ci/builds.rb
View file @
acc74978
...
@@ -107,7 +107,7 @@ FactoryGirl.define do
...
@@ -107,7 +107,7 @@ FactoryGirl.define do
end
end
trait
:triggered
do
trait
:triggered
do
trigger_request
factory: :ci_trigger_request_with_variables
trigger_request
factory: :ci_trigger_request_with_variables
# TODO:
end
end
after
(
:build
)
do
|
build
,
evaluator
|
after
(
:build
)
do
|
build
,
evaluator
|
...
...
spec/factories/ci/trigger_requests.rb
View file @
acc74978
...
@@ -2,14 +2,13 @@ FactoryGirl.define do
...
@@ -2,14 +2,13 @@ FactoryGirl.define do
factory
:ci_trigger_request
,
class:
Ci
::
TriggerRequest
do
factory
:ci_trigger_request
,
class:
Ci
::
TriggerRequest
do
trigger
factory: :ci_trigger
trigger
factory: :ci_trigger
# TODO:
factory
:ci_trigger_request_with_variables
do
# factory :ci_trigger_request_with_variables do
variables
do
# variables do
{
# {
TRIGGER_KEY_1
:
'TRIGGER_VALUE_1'
,
# TRIGGER_KEY_1: 'TRIGGER_VALUE_1',
TRIGGER_KEY_2
:
'TRIGGER_VALUE_2'
# TRIGGER_KEY_2: 'TRIGGER_VALUE_2'
}
# }
end
# end
end
# end
end
end
end
end
spec/features/projects/jobs_spec.rb
View file @
acc74978
...
@@ -292,7 +292,7 @@ feature 'Jobs' do
...
@@ -292,7 +292,7 @@ feature 'Jobs' do
end
end
feature
'Variables'
do
feature
'Variables'
do
let
(
:trigger_request
)
{
create
(
:ci_trigger_request_with_variables
)
}
let
(
:trigger_request
)
{
create
(
:ci_trigger_request_with_variables
)
}
# TODO:
let
(
:job
)
do
let
(
:job
)
do
create
:ci_build
,
pipeline:
pipeline
,
trigger_request:
trigger_request
create
:ci_build
,
pipeline:
pipeline
,
trigger_request:
trigger_request
...
...
spec/models/ci/build_spec.rb
View file @
acc74978
...
@@ -1492,7 +1492,7 @@ describe Ci::Build do
...
@@ -1492,7 +1492,7 @@ describe Ci::Build do
context
'when build is for triggers'
do
context
'when build is for triggers'
do
let
(
:trigger
)
{
create
(
:ci_trigger
,
project:
project
)
}
let
(
:trigger
)
{
create
(
:ci_trigger
,
project:
project
)
}
let
(
:trigger_request
)
{
create
(
:ci_trigger_request_with_variables
,
pipeline:
pipeline
,
trigger:
trigger
)
}
let
(
:trigger_request
)
{
create
(
:ci_trigger_request_with_variables
,
pipeline:
pipeline
,
trigger:
trigger
)
}
# TODO:
let
(
:user_trigger_variable
)
do
let
(
:user_trigger_variable
)
do
{
key: :TRIGGER_KEY_1
,
value:
'TRIGGER_VALUE_1'
,
public:
false
}
{
key: :TRIGGER_KEY_1
,
value:
'TRIGGER_VALUE_1'
,
public:
false
}
end
end
...
...
spec/requests/api/runner_spec.rb
View file @
acc74978
...
@@ -559,7 +559,7 @@ describe API::Runner do
...
@@ -559,7 +559,7 @@ describe API::Runner do
before
do
before
do
trigger
=
create
(
:ci_trigger
,
project:
project
)
trigger
=
create
(
:ci_trigger
,
project:
project
)
create
(
:ci_trigger_request_with_variables
,
pipeline:
pipeline
,
builds:
[
job
],
trigger:
trigger
)
create
(
:ci_trigger_request_with_variables
,
pipeline:
pipeline
,
builds:
[
job
],
trigger:
trigger
)
# TODO:
project
.
variables
<<
Ci
::
Variable
.
new
(
key:
'SECRET_KEY'
,
value:
'secret_value'
)
project
.
variables
<<
Ci
::
Variable
.
new
(
key:
'SECRET_KEY'
,
value:
'secret_value'
)
end
end
...
...
spec/requests/api/v3/triggers_spec.rb
View file @
acc74978
...
@@ -37,7 +37,7 @@ describe API::V3::Triggers do
...
@@ -37,7 +37,7 @@ describe API::V3::Triggers do
it
'returns unauthorized if token is for different project'
do
it
'returns unauthorized if token is for different project'
do
post
v3_api
(
"/projects/
#{
project2
.
id
}
/trigger/builds"
),
options
.
merge
(
ref:
'master'
)
post
v3_api
(
"/projects/
#{
project2
.
id
}
/trigger/builds"
),
options
.
merge
(
ref:
'master'
)
expect
(
response
).
to
have_http_status
(
40
1
)
expect
(
response
).
to
have_http_status
(
40
4
)
end
end
end
end
...
...
spec/views/projects/jobs/show.html.haml_spec.rb
View file @
acc74978
...
@@ -197,7 +197,7 @@ describe 'projects/jobs/show' do
...
@@ -197,7 +197,7 @@ describe 'projects/jobs/show' do
end
end
describe
'shows trigger variables in sidebar'
do
describe
'shows trigger variables in sidebar'
do
let
(
:trigger_request
)
{
create
(
:ci_trigger_request_with_variables
,
pipeline:
pipeline
)
}
let
(
:trigger_request
)
{
create
(
:ci_trigger_request_with_variables
,
pipeline:
pipeline
)
}
# TODO:
before
do
before
do
build
.
trigger_request
=
trigger_request
build
.
trigger_request
=
trigger_request
...
...
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