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
e4416700
Commit
e4416700
authored
May 15, 2019
by
Mathieu Parent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add auto_devops_* to project API
The auto_devops object sometimes doesn't exists. We may need to create it.
parent
5028f5d7
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
67 additions
and
2 deletions
+67
-2
app/models/concerns/project_api_compatibility.rb
app/models/concerns/project_api_compatibility.rb
+10
-0
doc/api/projects.md
doc/api/projects.md
+6
-0
lib/api/entities.rb
lib/api/entities.rb
+4
-0
lib/api/helpers/projects_helpers.rb
lib/api/helpers/projects_helpers.rb
+4
-0
spec/models/concerns/project_api_compatibility_spec.rb
spec/models/concerns/project_api_compatibility_spec.rb
+23
-2
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+20
-0
No files found.
app/models/concerns/project_api_compatibility.rb
View file @
e4416700
...
...
@@ -7,4 +7,14 @@ module ProjectAPICompatibility
def
build_git_strategy
=
(
value
)
write_attribute
(
:build_allow_git_fetch
,
value
==
'fetch'
)
end
def
auto_devops_enabled
=
(
value
)
self
.
build_auto_devops
if
self
.
auto_devops
&
.
enabled
.
nil?
self
.
auto_devops
.
update!
enabled:
value
end
def
auto_devops_deploy_strategy
=
(
value
)
self
.
build_auto_devops
if
self
.
auto_devops
&
.
enabled
.
nil?
self
.
auto_devops
.
update!
deploy_strategy:
value
end
end
doc/api/projects.md
View file @
e4416700
...
...
@@ -738,6 +738,8 @@ POST /projects
|
`auto_cancel_pending_pipelines`
| string | no | Auto-cancel pending pipelines (Note: this is not a boolean, but enabled/disabled |
|
`build_coverage_regex`
| string | no | Test coverage parsing |
|
`ci_config_path`
| string | no | The path to CI config file |
|
`auto_devops_enabled`
| boolean | no | Enable Auto DevOps for this project |
|
`auto_devops_deploy_strategy`
| string | no | Auto Deploy strategy (
`continuous`
,
`manual`
or
`timed_incremental`
) |
|
`repository_storage`
| string | no | Which storage shard the repository is on. Available only to admins |
|
`approvals_before_merge`
| integer | no |
**[STARTER]**
How many approvers should approve merge requests by default |
|
`mirror`
| boolean | no |
**[STARTER]**
Enables pull mirroring in a project |
...
...
@@ -793,6 +795,8 @@ POST /projects/user/:user_id
|
`auto_cancel_pending_pipelines`
| string | no | Auto-cancel pending pipelines (Note: this is not a boolean, but enabled/disabled |
|
`build_coverage_regex`
| string | no | Test coverage parsing |
|
`ci_config_path`
| string | no | The path to CI config file |
|
`auto_devops_enabled`
| boolean | no | Enable Auto DevOps for this project |
|
`auto_devops_deploy_strategy`
| string | no | Auto Deploy strategy (
`continuous`
,
`manual`
or
`timed_incremental`
) |
|
`repository_storage`
| string | no | Which storage shard the repository is on. Available only to admins |
|
`approvals_before_merge`
| integer | no |
**[STARTER]**
How many approvers should approve merge requests by default |
|
`external_authorization_classification_label`
| string | no |
**[CORE ONLY]**
The classification label for the project |
...
...
@@ -848,6 +852,8 @@ PUT /projects/:id
|
`build_coverage_regex`
| string | no | Test coverage parsing |
|
`ci_config_path`
| string | no | The path to CI config file |
|
`ci_default_git_depth`
| integer | no | Default number of revisions for
[
shallow cloning
](
../user/project/pipelines/settings.md#git-shallow-clone
)
|
|
`auto_devops_enabled`
| boolean | no | Enable Auto DevOps for this project |
|
`auto_devops_deploy_strategy`
| string | no | Auto Deploy strategy (
`continuous`
,
`manual`
or
`timed_incremental`
) |
|
`repository_storage`
| string | no | Which storage shard the repository is on. Available only to admins |
|
`approvals_before_merge`
| integer | no |
**[STARTER]**
How many approvers should approve merge request by default |
|
`external_authorization_classification_label`
| string | no |
**[CORE ONLY]**
The classification label for the project |
...
...
lib/api/entities.rb
View file @
e4416700
...
...
@@ -294,6 +294,10 @@ module API
options
[
:statistics
]
&&
Ability
.
allowed?
(
options
[
:current_user
],
:read_statistics
,
project
)
}
expose
:external_authorization_classification_label
expose
:auto_devops_enabled?
,
as: :auto_devops_enabled
expose
:auto_devops_deploy_strategy
do
|
project
,
options
|
project
.
auto_devops
.
nil?
?
'continuous'
:
project
.
auto_devops
.
deploy_strategy
end
# rubocop: disable CodeReuse/ActiveRecord
def
self
.
preload_relation
(
projects_relation
,
options
=
{})
...
...
lib/api/helpers/projects_helpers.rb
View file @
e4416700
...
...
@@ -44,6 +44,8 @@ module API
optional
:initialize_with_readme
,
type:
Boolean
,
desc:
"Initialize a project with a README.md"
optional
:external_authorization_classification_label
,
type:
String
,
desc:
'The classification label for the project'
optional
:ci_default_git_depth
,
type:
Integer
,
desc:
'Default number of revisions for shallow cloning'
optional
:auto_devops_enabled
,
type:
Boolean
,
desc:
'Flag indication if Auto DevOps is enabled'
optional
:auto_devops_deploy_strategy
,
type:
String
,
values:
%w(continuous manual timed_incremental)
,
desc:
'Auto Deploy strategy'
end
params
:optional_project_params_ee
do
...
...
@@ -62,6 +64,8 @@ module API
def
self
.
update_params_at_least_one_of
[
:auto_devops_enabled
,
:auto_devops_deploy_strategy
,
:auto_cancel_pending_pipelines
,
:build_coverage_regex
,
:build_git_strategy
,
...
...
spec/models/concerns/project_api_compatibility_spec.rb
View file @
e4416700
...
...
@@ -5,13 +5,34 @@ require 'spec_helper'
describe
ProjectAPICompatibility
do
let
(
:project
)
{
create
(
:project
)
}
# git_strategy
it
"converts build_git_strategy=fetch to build_allow_git_fetch=true"
do
project
.
update!
(
:build_git_strategy
,
'fetch'
)
project
.
update!
(
build_git_strategy:
'fetch'
)
expect
(
project
.
build_allow_git_fetch
).
to
eq
(
true
)
end
it
"converts build_git_strategy=clone to build_allow_git_fetch=false"
do
project
.
update!
(
:build_git_strategy
,
'clone'
)
project
.
update!
(
build_git_strategy:
'clone'
)
expect
(
project
.
build_allow_git_fetch
).
to
eq
(
false
)
end
# auto_devops_enabled
it
"converts auto_devops_enabled=false to auto_devops_enabled?=false"
do
expect
(
project
.
auto_devops_enabled?
).
to
eq
(
true
)
project
.
update!
(
auto_devops_enabled:
false
)
expect
(
project
.
auto_devops_enabled?
).
to
eq
(
false
)
end
it
"converts auto_devops_enabled=true to auto_devops_enabled?=true"
do
expect
(
project
.
auto_devops_enabled?
).
to
eq
(
true
)
project
.
update!
(
auto_devops_enabled:
true
)
expect
(
project
.
auto_devops_enabled?
).
to
eq
(
true
)
end
# auto_devops_deploy_strategy
it
"converts auto_devops_deploy_strategy=timed_incremental to auto_devops.deploy_strategy=timed_incremental"
do
expect
(
project
.
auto_devops
).
to
be_nil
project
.
update!
(
auto_devops_deploy_strategy:
'timed_incremental'
)
expect
(
project
.
auto_devops
.
deploy_strategy
).
to
eq
(
'timed_incremental'
)
end
end
spec/requests/api/projects_spec.rb
View file @
e4416700
...
...
@@ -1980,6 +1980,26 @@ describe API::Projects do
'-/system/project/avatar/'
\
"
#{
project3
.
id
}
/banana_sample.gif"
)
end
it
'updates auto_devops_deploy_strategy'
do
project_param
=
{
auto_devops_deploy_strategy:
'timed_incremental'
}
put
api
(
"/projects/
#{
project3
.
id
}
"
,
user
),
params:
project_param
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
json_response
[
'auto_devops_deploy_strategy'
]).
to
eq
(
'timed_incremental'
)
end
it
'updates auto_devops_enabled'
do
project_param
=
{
auto_devops_enabled:
false
}
put
api
(
"/projects/
#{
project3
.
id
}
"
,
user
),
params:
project_param
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
json_response
[
'auto_devops_enabled'
]).
to
eq
(
false
)
end
end
context
'when authenticated as project maintainer'
do
...
...
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