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
24a8dec1
Commit
24a8dec1
authored
Mar 05, 2018
by
Rubén Dávila
Committed by
Eric Eastwood
Mar 05, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add backend for CI/CD "Repo by URL" projects
See
https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/4567
parent
f290e2ea
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
137 additions
and
2 deletions
+137
-2
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+6
-2
ee/app/controllers/ee/projects_controller.rb
ee/app/controllers/ee/projects_controller.rb
+12
-0
ee/app/models/license.rb
ee/app/models/license.rb
+1
-0
ee/app/services/ee/projects/create_service.rb
ee/app/services/ee/projects/create_service.rb
+9
-0
ee/app/services/projects/setup_ci_cd.rb
ee/app/services/projects/setup_ci_cd.rb
+32
-0
ee/spec/services/projects/create_service_spec.rb
ee/spec/services/projects/create_service_spec.rb
+33
-0
ee/spec/services/projects/setup_ci_cd_spec.rb
ee/spec/services/projects/setup_ci_cd_spec.rb
+44
-0
No files found.
app/controllers/projects_controller.rb
View file @
24a8dec1
...
...
@@ -43,7 +43,7 @@ class ProjectsController < Projects::ApplicationController
cookies
[
:issue_board_welcome_hidden
]
=
{
path:
project_path
(
@project
),
value:
nil
,
expires:
Time
.
at
(
0
)
}
redirect_to
(
project_path
(
@project
),
project_path
(
@project
,
custom_import_params
),
notice:
_
(
"Project '%{project_name}' was successfully created."
)
%
{
project_name:
@project
.
name
}
)
else
...
...
@@ -105,7 +105,7 @@ class ProjectsController < Projects::ApplicationController
def
show
if
@project
.
import_in_progress?
redirect_to
project_import_path
(
@project
)
redirect_to
project_import_path
(
@project
,
custom_import_params
)
return
end
...
...
@@ -361,6 +361,10 @@ class ProjectsController < Projects::ApplicationController
]
end
def
custom_import_params
{}
end
def
repo_exists?
project
.
repository_exists?
&&
!
project
.
empty_repo?
...
...
ee/app/controllers/ee/projects_controller.rb
View file @
24a8dec1
module
EE
module
ProjectsController
extend
::
Gitlab
::
Utils
::
Override
def
project_params_attributes
super
+
project_params_ee
end
...
...
@@ -21,7 +23,17 @@ module EE
mirror_trigger_builds
mirror_user_id
external_authorization_classification_label
ci_cd_only
]
end
override
:custom_import_params
def
custom_import_params
custom_params
=
super
ci_cd_param
=
params
.
dig
(
:project
,
:ci_cd_only
)
||
params
[
:ci_cd_only
]
custom_params
[
:ci_cd_only
]
=
ci_cd_param
if
ci_cd_param
==
'true'
custom_params
end
end
end
ee/app/models/license.rb
View file @
24a8dec1
...
...
@@ -54,6 +54,7 @@ class License < ActiveRecord::Base
commit_committer_check
project_creation_level
external_authorization_service
ci_cd_projects
]
.
freeze
EEU_FEATURES
=
EEP_FEATURES
+
%i[
...
...
ee/app/services/ee/projects/create_service.rb
View file @
24a8dec1
...
...
@@ -9,6 +9,7 @@ module EE
mirror
=
params
.
delete
(
:mirror
)
mirror_user_id
=
params
.
delete
(
:mirror_user_id
)
mirror_trigger_builds
=
params
.
delete
(
:mirror_trigger_builds
)
ci_cd_only
=
params
.
delete
(
:ci_cd_only
)
project
=
super
do
|
project
|
# Repository size limit comes as MB from the view
...
...
@@ -22,6 +23,8 @@ module EE
end
if
project
&
.
persisted?
setup_ci_cd_project
if
ci_cd_only
log_geo_event
(
project
)
log_audit_event
(
project
)
end
...
...
@@ -55,6 +58,12 @@ module EE
end
end
def
setup_ci_cd_project
return
unless
::
License
.
feature_available?
(
:ci_cd_projects
)
::
Projects
::
SetupCiCd
.
new
(
project
,
current_user
).
execute
end
def
log_audit_event
(
project
)
::
AuditEventService
.
new
(
current_user
,
...
...
ee/app/services/projects/setup_ci_cd.rb
0 → 100644
View file @
24a8dec1
module
Projects
class
SetupCiCd
<
BaseService
def
execute
return
if
project
.
import_url
.
blank?
update_project
disable_project_features
end
private
def
update_project
project
.
update_attributes
(
container_registry_enabled:
false
,
mirror:
true
,
mirror_trigger_builds:
true
,
mirror_overwrites_diverged_branches:
true
,
only_mirror_protected_branches:
false
,
mirror_user_id:
current_user
.
id
)
end
def
disable_project_features
project
.
project_feature
.
update_attributes
(
issues_access_level:
ProjectFeature
::
DISABLED
,
merge_requests_access_level:
ProjectFeature
::
DISABLED
,
wiki_access_level:
ProjectFeature
::
DISABLED
,
snippets_access_level:
ProjectFeature
::
DISABLED
)
end
end
end
ee/spec/services/projects/create_service_spec.rb
View file @
24a8dec1
...
...
@@ -9,6 +9,39 @@ describe Projects::CreateService, '#execute' do
}
end
context
'with a CI/CD only project'
do
before
do
opts
.
merge!
(
ci_cd_only:
true
,
import_url:
'http://foo.com'
)
end
context
'when CI/CD projects feature is available'
do
before
do
stub_licensed_features
(
ci_cd_projects:
true
)
end
it
'calls the service to setup CI/CD on the project'
do
expect
(
Projects
::
SetupCiCd
).
to
receive_message_chain
(
:new
,
:execute
)
create_project
(
user
,
opts
)
end
end
context
'when CI/CD projects feature is not available'
do
before
do
stub_licensed_features
(
ci_cd_projects:
false
)
end
it
"doesn't call the service to setup CI/CD on the project"
do
expect
(
Projects
::
SetupCiCd
).
not_to
receive
(
:new
)
create_project
(
user
,
opts
)
end
end
end
context
'repository_size_limit assignment as Bytes'
do
let
(
:admin_user
)
{
create
(
:user
,
admin:
true
)
}
...
...
ee/spec/services/projects/setup_ci_cd_spec.rb
0 → 100644
View file @
24a8dec1
require
'spec_helper'
describe
Projects
::
SetupCiCd
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
creator:
user
,
import_url:
'http://foo.com'
)
}
subject
do
described_class
.
new
(
project
,
project
.
creator
)
end
it
'sets up pull mirroring on the project'
do
subject
.
execute
expect
(
project
.
mirror
).
to
be_truthy
expect
(
project
.
mirror_trigger_builds
).
to
be_truthy
expect
(
project
.
mirror_user_id
).
to
eq
(
user
.
id
)
end
it
'disables some features'
do
subject
.
execute
project_feature
=
project
.
project_feature
expect
(
project
.
container_registry_enabled
).
to
be_falsey
expect
(
project_feature
).
not_to
be_issues_enabled
expect
(
project_feature
).
not_to
be_merge_requests_enabled
expect
(
project_feature
).
not_to
be_wiki_enabled
expect
(
project_feature
.
snippets_access_level
).
to
eq
(
ProjectFeature
::
DISABLED
)
end
context
'when import_url is blank'
do
before
do
project
.
update_attribute
(
:import_url
,
nil
)
end
it
"doesn't update the project"
do
expect
(
project
).
not_to
receive
(
:update_project
)
expect
(
project
).
not_to
receive
(
:disable_project_features
)
subject
.
execute
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