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
bf9c09d7
Commit
bf9c09d7
authored
Dec 12, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add basic implementation of cross project pipeline service
parent
d426d249
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
1 deletion
+75
-1
ee/app/models/ee/ci/bridge.rb
ee/app/models/ee/ci/bridge.rb
+14
-1
ee/app/services/ci/create_cross_project_pipeline_service.rb
ee/app/services/ci/create_cross_project_pipeline_service.rb
+47
-0
ee/app/workers/ci/create_cross_project_pipeline_worker.rb
ee/app/workers/ci/create_cross_project_pipeline_worker.rb
+14
-0
No files found.
ee/app/models/ee/ci/bridge.rb
View file @
bf9c09d7
...
...
@@ -6,6 +6,7 @@ module EE
extend
ActiveSupport
::
Concern
prepended
do
serialize
:options
# rubocop:disable Cop/ActiveRecordSerialize
has_many
:sourced_pipelines
,
class_name:
::
Ci
::
Sources
::
Pipeline
,
foreign_key: :source_job_id
...
...
@@ -35,7 +36,19 @@ module EE
end
def
schedule_downstream_pipeline!
raise
NotImplementedError
CreateCrossProjectPipelineWorker
.
perform_async
(
self
.
id
)
end
def
target_user
self
.
user
end
def
target_project_name
options
.
dig
(
:trigger
,
:project
)
end
def
target_ref
options
.
dig
(
:trigger
,
:branch
)
end
end
end
...
...
ee/app/services/ci/create_cross_project_pipeline_service.rb
0 → 100644
View file @
bf9c09d7
# frozen_string_literal: true
module
Ci
class
CreateCrossProjectPipelineService
<
::
BaseService
include
Gitlab
::
Utils
::
StrongMemoize
def
execute
(
bridge
)
@bridge
=
bridge
unless
can_create_cross_pipeline?
return
bridge
.
drop!
(
:insufficient_permissions
)
end
create_pipeline
do
|
pipeline
|
source
=
bridge
.
sourced_pipelines
.
build
(
source_pipeline:
bridge
.
pipeline
,
source_project:
bridge
.
project
,
project:
target_project
,
pipeline:
pipeline
)
pipeline
.
source_pipeline
=
source
end
end
private
def
can_create_cross_pipeline?
can?
(
current_user
,
:create_pipeline
,
project
)
&&
can?
(
current_user
,
:create_pipeline
,
target_project
)
&&
can?
(
@bridge
.
target_user
,
:create_pipeline
,
target_project
)
end
def
create_pipeline
::
Ci
::
CreatePipelineService
.
new
(
target_project
,
@bridge
.
target_user
,
ref:
@bridge
.
target_ref
)
.
execute
(
:pipeline
,
ignore_skip_ci:
true
)
do
|
pipeline
|
yield
pipeline
end
end
def
target_project
strong_memoize
(
:target_project
)
do
Project
.
find_by_full_path
(
@bridge
.
target_project_name
)
end
end
end
end
ee/app/workers/ci/create_cross_project_pipeline_worker.rb
0 → 100644
View file @
bf9c09d7
# frozen_string_literal: true
class
CreateCrossProjectPipelineWorker
include
::
ApplicationWorker
include
::
PipelineQueue
def
perform
(
bridge_id
)
::
Ci
::
Bridge
.
find
(
bridge_id
).
try
do
|
bridge
|
::
Ci
::
CreateCrossProjectPipelineService
.
new
(
bridge
.
project
,
bridge
.
user
)
.
execute
(
bridge
)
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