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
555cdade
Commit
555cdade
authored
6 years ago
by
Dylan Griffith
Committed by
Kamil Trzciński
6 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "Enable Auto DevOps instance-wide on GitLab.com"
parent
ce18246c
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
54 additions
and
28 deletions
+54
-28
app/models/project.rb
app/models/project.rb
+5
-3
app/models/project_auto_devops.rb
app/models/project_auto_devops.rb
+1
-5
app/services/projects/update_service.rb
app/services/projects/update_service.rb
+1
-1
doc/topics/autodevops/index.md
doc/topics/autodevops/index.md
+5
-0
spec/models/project_auto_devops_spec.rb
spec/models/project_auto_devops_spec.rb
+3
-3
spec/models/project_spec.rb
spec/models/project_spec.rb
+32
-16
spec/spec_helper.rb
spec/spec_helper.rb
+7
-0
No files found.
app/models/project.rb
View file @
555cdade
...
...
@@ -27,6 +27,7 @@ class Project < ActiveRecord::Base
include
FastDestroyAll
::
Helpers
include
WithUploads
include
BatchDestroyDependentAssociations
include
FeatureGate
extend
Gitlab
::
Cache
::
RequestCache
extend
Gitlab
::
ConfigHelper
...
...
@@ -519,18 +520,19 @@ class Project < ActiveRecord::Base
def
auto_devops_enabled?
if
auto_devops
&
.
enabled
.
nil?
Gitlab
::
CurrentSettings
.
auto_devops
_enabled?
has_auto_devops_implicitly
_enabled?
else
auto_devops
.
enabled?
end
end
def
has_auto_devops_implicitly_enabled?
auto_devops
&
.
enabled
.
nil?
&&
Gitlab
::
CurrentSettings
.
auto_devops_enabled?
auto_devops
&
.
enabled
.
nil?
&&
(
Gitlab
::
CurrentSettings
.
auto_devops_enabled?
||
Feature
.
enabled?
(
:force_autodevops_on_by_default
,
self
))
end
def
has_auto_devops_implicitly_disabled?
auto_devops
&
.
enabled
.
nil?
&&
!
Gitlab
::
CurrentSettings
.
auto_devops_enabled?
auto_devops
&
.
enabled
.
nil?
&&
!
(
Gitlab
::
CurrentSettings
.
auto_devops_enabled?
||
Feature
.
enabled?
(
:force_autodevops_on_by_default
,
self
))
end
def
empty_repo?
...
...
This diff is collapsed.
Click to expand it.
app/models/project_auto_devops.rb
View file @
555cdade
...
...
@@ -47,12 +47,8 @@ class ProjectAutoDevops < ActiveRecord::Base
end
def
needs_to_create_deploy_token?
auto_devops_enabled?
&&
project
.
auto_devops_enabled?
&&
!
project
.
public?
&&
!
project
.
deploy_tokens
.
find_by
(
name:
DeployToken
::
GITLAB_DEPLOY_TOKEN_NAME
).
present?
end
def
auto_devops_enabled?
Gitlab
::
CurrentSettings
.
auto_devops_enabled?
||
enabled?
end
end
This diff is collapsed.
Click to expand it.
app/services/projects/update_service.rb
View file @
555cdade
...
...
@@ -30,7 +30,7 @@ module Projects
def
run_auto_devops_pipeline?
return
false
if
project
.
repository
.
gitlab_ci_yml
||
!
project
.
auto_devops
&
.
previous_changes
&
.
include?
(
'enabled'
)
project
.
auto_devops
.
enabled?
||
(
project
.
auto_devops
.
enabled
.
nil?
&&
Gitlab
::
CurrentSettings
.
auto_devops_enabled?
)
project
.
auto_devops
_enabled?
end
private
...
...
This diff is collapsed.
Click to expand it.
doc/topics/autodevops/index.md
View file @
555cdade
...
...
@@ -233,6 +233,11 @@ in **Admin Area > Settings > Continuous Integration and Deployment**. Doing that
all the projects that haven't explicitly set an option will have Auto DevOps
enabled by default.
NOTE:
**Note:**
There is also a feature flag to enable Auto DevOps to a percentage of projects
which can be enabled from the console with
`Feature.get(:force_autodevops_on_by_default).enable_percentage_of_actors(10)`
.
### Deployment strategy
> [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/issues/38542) in GitLab 11.0.
...
...
This diff is collapsed.
Click to expand it.
spec/models/project_auto_devops_spec.rb
View file @
555cdade
...
...
@@ -100,7 +100,7 @@ describe ProjectAutoDevops do
end
end
describe
'#
set
_gitlab_deploy_token'
do
describe
'#
create
_gitlab_deploy_token'
do
let
(
:auto_devops
)
{
build
(
:project_auto_devops
,
project:
project
)
}
context
'when the project is public'
do
...
...
@@ -144,9 +144,9 @@ describe ProjectAutoDevops do
end
end
context
'when autodevops is enabled at instance
l
level'
do
context
'when autodevops is enabled at instance level'
do
let
(
:project
)
{
create
(
:project
,
:repository
,
:internal
)
}
let
(
:auto_devops
)
{
build
(
:project_auto_devops
,
:disabled
,
project:
project
)
}
let
(
:auto_devops
)
{
build
(
:project_auto_devops
,
enabled:
nil
,
project:
project
)
}
it
'should create a deploy token'
do
allow
(
Gitlab
::
CurrentSettings
).
to
receive
(
:auto_devops_enabled?
).
and_return
(
true
)
...
...
This diff is collapsed.
Click to expand it.
spec/models/project_spec.rb
View file @
555cdade
...
...
@@ -3259,6 +3259,11 @@ describe Project do
end
describe
'#auto_devops_enabled?'
do
before
do
allow
(
Feature
).
to
receive
(
:enabled?
).
and_call_original
Feature
.
get
(
:force_autodevops_on_by_default
).
enable_percentage_of_actors
(
0
)
end
set
(
:project
)
{
create
(
:project
)
}
subject
{
project
.
auto_devops_enabled?
}
...
...
@@ -3268,19 +3273,14 @@ describe Project do
stub_application_setting
(
auto_devops_enabled:
true
)
end
it
'auto devops is implicitly enabled'
do
expect
(
project
.
auto_devops
).
to
be_nil
expect
(
project
).
to
be_auto_devops_enabled
end
it
{
is_expected
.
to
be_truthy
}
context
'when explicitly enabled'
do
before
do
create
(
:project_auto_devops
,
project:
project
)
end
it
"auto devops is enabled"
do
expect
(
project
).
to
be_auto_devops_enabled
end
it
{
is_expected
.
to
be_truthy
}
end
context
'when explicitly disabled'
do
...
...
@@ -3288,9 +3288,7 @@ describe Project do
create
(
:project_auto_devops
,
project:
project
,
enabled:
false
)
end
it
"auto devops is disabled"
do
expect
(
project
).
not_to
be_auto_devops_enabled
end
it
{
is_expected
.
to
be_falsey
}
end
end
...
...
@@ -3299,19 +3297,22 @@ describe Project do
stub_application_setting
(
auto_devops_enabled:
false
)
end
it
'auto devops is implicitly disabled'
do
expect
(
project
.
auto_devops
).
to
be_nil
expect
(
project
).
not_to
be_auto_devops_enabled
end
it
{
is_expected
.
to
be_falsey
}
context
'when explicitly enabled'
do
before
do
create
(
:project_auto_devops
,
project:
project
)
end
it
"auto devops is enabled"
do
expect
(
project
).
to
be_auto_devops_enabled
it
{
is_expected
.
to
be_truthy
}
end
context
'when force_autodevops_on_by_default is enabled for the project'
do
before
do
Feature
.
get
(
:force_autodevops_on_by_default
).
enable_percentage_of_actors
(
100
)
end
it
{
is_expected
.
to
be_truthy
}
end
end
end
...
...
@@ -3361,6 +3362,11 @@ describe Project do
end
describe
'#has_auto_devops_implicitly_disabled?'
do
before
do
allow
(
Feature
).
to
receive
(
:enabled?
).
and_call_original
Feature
.
get
(
:force_autodevops_on_by_default
).
enable_percentage_of_actors
(
0
)
end
set
(
:project
)
{
create
(
:project
)
}
context
'when enabled in settings'
do
...
...
@@ -3382,6 +3388,16 @@ describe Project do
expect
(
project
).
to
have_auto_devops_implicitly_disabled
end
context
'when force_autodevops_on_by_default is enabled for the project'
do
before
do
Feature
.
get
(
:force_autodevops_on_by_default
).
enable_percentage_of_actors
(
100
)
end
it
'does not have auto devops implicitly disabled'
do
expect
(
project
).
not_to
have_auto_devops_implicitly_disabled
end
end
context
'when explicitly disabled'
do
before
do
create
(
:project_auto_devops
,
project:
project
,
enabled:
false
)
...
...
This diff is collapsed.
Click to expand it.
spec/spec_helper.rb
View file @
555cdade
...
...
@@ -111,6 +111,13 @@ RSpec.configure do |config|
config
.
before
(
:example
)
do
# Enable all features by default for testing
allow
(
Feature
).
to
receive
(
:enabled?
)
{
true
}
# The following can be removed when we remove the staged rollout strategy
# and we can just enable it using instance wide settings
# (ie. ApplicationSetting#auto_devops_enabled)
allow
(
Feature
).
to
receive
(
:enabled?
)
.
with
(
:force_autodevops_on_by_default
,
anything
)
.
and_return
(
false
)
end
config
.
before
(
:example
,
:request_store
)
do
...
...
This diff is collapsed.
Click to expand it.
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