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
08d47ff7
Commit
08d47ff7
authored
Feb 01, 2019
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[EE] Reduce diff with CE in Ci::PipelineTriggerService
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
8850e61c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
28 deletions
+52
-28
app/services/ci/pipeline_trigger_service.rb
app/services/ci/pipeline_trigger_service.rb
+7
-28
ee/app/services/ee/ci/pipeline_trigger_service.rb
ee/app/services/ee/ci/pipeline_trigger_service.rb
+45
-0
No files found.
app/services/ci/pipeline_trigger_service.rb
View file @
08d47ff7
...
...
@@ -31,41 +31,18 @@ module Ci
end
end
def
create_pipeline_from_job
(
job
)
# this check is to not leak the presence of the project if user cannot read it
return
unless
can?
(
job
.
user
,
:read_project
,
project
)
return
error
(
"400 Job has to be running"
,
400
)
unless
job
.
running?
pipeline
=
Ci
::
CreatePipelineService
.
new
(
project
,
job
.
user
,
ref:
params
[
:ref
])
.
execute
(
:pipeline
,
ignore_skip_ci:
true
)
do
|
pipeline
|
source
=
job
.
sourced_pipelines
.
build
(
source_pipeline:
job
.
pipeline
,
source_project:
job
.
project
,
pipeline:
pipeline
,
project:
project
)
pipeline
.
source_pipeline
=
source
pipeline
.
variables
.
build
(
variables
)
end
if
pipeline
.
persisted?
success
(
pipeline:
pipeline
)
else
error
(
pipeline
.
errors
.
messages
,
400
)
end
end
def
trigger_from_token
strong_memoize
(
:trigger
)
do
Ci
::
Trigger
.
find_by_token
(
params
[
:token
].
to_s
)
end
end
def
job_from_token
strong_memoize
(
:job
)
do
Ci
::
Build
.
find_by_token
(
params
[
:token
].
to_s
)
def
create_pipeline_from_job
(
job
)
# overriden in EE
end
def
job_from_token
# overriden in EE
end
def
variables
...
...
@@ -75,3 +52,5 @@ module Ci
end
end
end
Ci
::
PipelineTriggerService
.
prepend
(
EE
::
Ci
::
PipelineTriggerService
)
ee/app/services/ee/ci/pipeline_trigger_service.rb
0 → 100644
View file @
08d47ff7
# frozen_string_literal: true
module
EE
module
Ci
module
PipelineTriggerService
extend
::
Gitlab
::
Utils
::
Override
include
::
Gitlab
::
Utils
::
StrongMemoize
private
override
:create_pipeline_from_job
def
create_pipeline_from_job
(
job
)
# this check is to not leak the presence of the project if user cannot read it
return
unless
can?
(
job
.
user
,
:read_project
,
project
)
return
error
(
"400 Job has to be running"
,
400
)
unless
job
.
running?
pipeline
=
::
Ci
::
CreatePipelineService
.
new
(
project
,
job
.
user
,
ref:
params
[
:ref
])
.
execute
(
:pipeline
,
ignore_skip_ci:
true
)
do
|
pipeline
|
source
=
job
.
sourced_pipelines
.
build
(
source_pipeline:
job
.
pipeline
,
source_project:
job
.
project
,
pipeline:
pipeline
,
project:
project
)
pipeline
.
source_pipeline
=
source
pipeline
.
variables
.
build
(
variables
)
end
if
pipeline
.
persisted?
success
(
pipeline:
pipeline
)
else
error
(
pipeline
.
errors
.
messages
,
400
)
end
end
override
:job_from_token
def
job_from_token
strong_memoize
(
:job
)
do
::
Ci
::
Build
.
find_by_token
(
params
[
:token
].
to_s
)
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