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
0
Merge Requests
0
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
Tatuya Kamada
gitlab-ce
Commits
d2d30cff
Commit
d2d30cff
authored
Feb 14, 2017
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial implementation for default artifacts expiration
TODO: Add tests and screenshots
parent
14527293
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
77 additions
and
11 deletions
+77
-11
app/controllers/admin/application_settings_controller.rb
app/controllers/admin/application_settings_controller.rb
+1
-0
app/models/application_setting.rb
app/models/application_setting.rb
+17
-2
app/models/ci/build.rb
app/models/ci/build.rb
+11
-0
app/views/admin/application_settings/_form.html.haml
app/views/admin/application_settings/_form.html.haml
+8
-1
db/migrate/20170214084746_add_default_artifacts_expiration_to_application_settings.rb
...d_default_artifacts_expiration_to_application_settings.rb
+11
-0
doc/user/admin_area/settings/continuous_integration.md
doc/user/admin_area/settings/continuous_integration.md
+22
-4
lib/api/settings.rb
lib/api/settings.rb
+5
-2
lib/ci/api/builds.rb
lib/ci/api/builds.rb
+1
-1
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+1
-1
No files found.
app/controllers/admin/application_settings_controller.rb
View file @
d2d30cff
...
@@ -83,6 +83,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
...
@@ -83,6 +83,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
:akismet_api_key
,
:akismet_api_key
,
:akismet_enabled
,
:akismet_enabled
,
:container_registry_token_expire_delay
,
:container_registry_token_expire_delay
,
:default_artifacts_expiration
,
:default_branch_protection
,
:default_branch_protection
,
:default_group_visibility
,
:default_group_visibility
,
:default_project_visibility
,
:default_project_visibility
,
...
...
app/models/application_setting.rb
View file @
d2d30cff
...
@@ -76,6 +76,14 @@ class ApplicationSetting < ActiveRecord::Base
...
@@ -76,6 +76,14 @@ class ApplicationSetting < ActiveRecord::Base
presence:
true
,
presence:
true
,
numericality:
{
only_integer:
true
,
greater_than:
0
}
numericality:
{
only_integer:
true
,
greater_than:
0
}
validates
:max_artifacts_size
,
presence:
true
,
numericality:
{
only_integer:
true
,
greater_than:
0
}
validates
:default_artifacts_expiration
,
presence:
true
,
numericality:
{
only_integer:
true
,
greater_than_or_equal_to:
0
}
validates
:container_registry_token_expire_delay
,
validates
:container_registry_token_expire_delay
,
presence:
true
,
presence:
true
,
numericality:
{
only_integer:
true
,
greater_than:
0
}
numericality:
{
only_integer:
true
,
greater_than:
0
}
...
@@ -168,6 +176,7 @@ class ApplicationSetting < ActiveRecord::Base
...
@@ -168,6 +176,7 @@ class ApplicationSetting < ActiveRecord::Base
after_sign_up_text:
nil
,
after_sign_up_text:
nil
,
akismet_enabled:
false
,
akismet_enabled:
false
,
container_registry_token_expire_delay:
5
,
container_registry_token_expire_delay:
5
,
default_artifacts_expiration:
30
,
default_branch_protection:
Settings
.
gitlab
[
'default_branch_protection'
],
default_branch_protection:
Settings
.
gitlab
[
'default_branch_protection'
],
default_project_visibility:
Settings
.
gitlab
.
default_projects_features
[
'visibility_level'
],
default_project_visibility:
Settings
.
gitlab
.
default_projects_features
[
'visibility_level'
],
default_projects_limit:
Settings
.
gitlab
[
'default_projects_limit'
],
default_projects_limit:
Settings
.
gitlab
[
'default_projects_limit'
],
...
@@ -201,9 +210,9 @@ class ApplicationSetting < ActiveRecord::Base
...
@@ -201,9 +210,9 @@ class ApplicationSetting < ActiveRecord::Base
sign_in_text:
nil
,
sign_in_text:
nil
,
signin_enabled:
Settings
.
gitlab
[
'signin_enabled'
],
signin_enabled:
Settings
.
gitlab
[
'signin_enabled'
],
signup_enabled:
Settings
.
gitlab
[
'signup_enabled'
],
signup_enabled:
Settings
.
gitlab
[
'signup_enabled'
],
terminal_max_session_time:
0
,
two_factor_grace_period:
48
,
two_factor_grace_period:
48
,
user_default_external:
false
,
user_default_external:
false
terminal_max_session_time:
0
}
}
end
end
...
@@ -282,6 +291,12 @@ class ApplicationSetting < ActiveRecord::Base
...
@@ -282,6 +291,12 @@ class ApplicationSetting < ActiveRecord::Base
sidekiq_throttling_enabled
sidekiq_throttling_enabled
end
end
def
default_artifacts_expire_in
if
default_artifacts_expiration
.
nonzero?
"
#{
default_artifacts_expiration
}
days"
end
end
private
private
def
check_repository_storages
def
check_repository_storages
...
...
app/models/ci/build.rb
View file @
d2d30cff
...
@@ -513,6 +513,17 @@ module Ci
...
@@ -513,6 +513,17 @@ module Ci
end
end
end
end
def
set_artifacts_expire_in
(
expire_in
)
value
=
if
expire_in
expire_in
else
ApplicationSetting
.
current
.
default_artifacts_expire_in
end
self
.
artifacts_expire_in
=
value
end
def
has_expiring_artifacts?
def
has_expiring_artifacts?
artifacts_expire_at
.
present?
artifacts_expire_at
.
present?
end
end
...
...
app/views/admin/application_settings/_form.html.haml
View file @
d2d30cff
...
@@ -212,8 +212,15 @@
...
@@ -212,8 +212,15 @@
.col-sm-10
.col-sm-10
=
f
.
number_field
:max_artifacts_size
,
class:
'form-control'
=
f
.
number_field
:max_artifacts_size
,
class:
'form-control'
.help-block
.help-block
Set the maximum file size
each jobs's artifacts can have
Set the maximum file size
for each job's artifacts
=
link_to
"(?)"
,
help_page_path
(
"user/admin_area/settings/continuous_integration"
,
anchor:
"maximum-artifacts-size"
)
=
link_to
"(?)"
,
help_page_path
(
"user/admin_area/settings/continuous_integration"
,
anchor:
"maximum-artifacts-size"
)
.form-group
=
f
.
label
:default_artifacts_expiration
,
'Default artifacts expiration (days)'
,
class:
'control-label col-sm-2'
.col-sm-10
=
f
.
number_field
:default_artifacts_expiration
,
class:
'form-control'
.help-block
Set the default expiration time for each job's artifacts (0 as never expired)
=
link_to
"(?)"
,
help_page_path
(
"user/admin_area/settings/continuous_integration"
,
anchor:
"default-artifacts-expiration"
)
-
if
Gitlab
.
config
.
registry
.
enabled
-
if
Gitlab
.
config
.
registry
.
enabled
%fieldset
%fieldset
...
...
db/migrate/20170214084746_add_default_artifacts_expiration_to_application_settings.rb
0 → 100644
View file @
d2d30cff
class
AddDefaultArtifactsExpirationToApplicationSettings
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
def
change
add_column
:application_settings
,
:default_artifacts_expiration
,
:integer
,
default:
0
,
null:
false
end
end
doc/user/admin_area/settings/continuous_integration.md
View file @
d2d30cff
...
@@ -2,19 +2,37 @@
...
@@ -2,19 +2,37 @@
## Maximum artifacts size
## Maximum artifacts size
The maximum size of the
[
build artifacts
][
art-yml
]
can be set in the Admin
area
The maximum size of the
[
build artifacts
][
art-yml
]
can be set in the Admin
of your GitLab instance. The value is in MB and the default is 100MB. Note that
area of your GitLab instance. The value is in
*MB*
and the default is 100MB.
this setting is set for each build
.
Note that this setting is set for each job
.
1.
Go to
**Admin area > Settings**
(
`/admin/application_settings`
).
1.
Go to
**Admin area > Settings**
(
`/admin/application_settings`
).
![Admin area settings button](img/admin_area_settings_button.png)
![Admin area settings button](img/admin_area_settings_button.png)
1.
Change the value of
the
maximum artifacts size (in MB):
1.
Change the value of maximum artifacts size (in MB):
![Admin area maximum artifacts size](img/admin_area_maximum_artifacts_size.png)
![Admin area maximum artifacts size](img/admin_area_maximum_artifacts_size.png)
1.
Hit
**Save**
for the changes to take effect.
1.
Hit
**Save**
for the changes to take effect.
[
art-yml
]:
../../../administration/build_artifacts.md
## Default artifacts expiration time
The default expiration time of the
[
build artifacts
][
art-yml
]
can be set in
the Admin area of your GitLab instance. The value is in
*days*
and the
default is 30 days. Note that this setting is set for each job. Set it to
0 as never expired by default.
1.
Go to
**Admin area > Settings**
(
`/admin/application_settings`
).
![Admin area settings button](img/admin_area_settings_button.png)
1.
Change the value of default expiration time (in days):
![Admin area default artifacts expiration](img/admin_area_default_artifacts_expiration.png)
1.
Hit
**Save**
for the changes to take effect.
[
art-yml
]:
../../../administration/build_artifacts.md
[
art-yml
]:
../../../administration/build_artifacts.md
lib/api/settings.rb
View file @
d2d30cff
...
@@ -56,7 +56,8 @@ module API
...
@@ -56,7 +56,8 @@ module API
given
shared_runners_enabled:
->
(
val
)
{
val
}
do
given
shared_runners_enabled:
->
(
val
)
{
val
}
do
requires
:shared_runners_text
,
type:
String
,
desc:
'Shared runners text '
requires
:shared_runners_text
,
type:
String
,
desc:
'Shared runners text '
end
end
optional
:max_artifacts_size
,
type:
Integer
,
desc:
"Set the maximum file size each build's artifacts can have"
optional
:max_artifacts_size
,
type:
Integer
,
desc:
"Set the maximum file size for each job's artifacts"
optional
:default_artifacts_expiration
,
type:
Integer
,
desc:
"Set the default expiration time for each job's artifacts"
optional
:max_pages_size
,
type:
Integer
,
desc:
'Maximum size of pages in MB'
optional
:max_pages_size
,
type:
Integer
,
desc:
'Maximum size of pages in MB'
optional
:container_registry_token_expire_delay
,
type:
Integer
,
desc:
'Authorization token duration (minutes)'
optional
:container_registry_token_expire_delay
,
type:
Integer
,
desc:
'Authorization token duration (minutes)'
optional
:metrics_enabled
,
type:
Boolean
,
desc:
'Enable the InfluxDB metrics'
optional
:metrics_enabled
,
type:
Boolean
,
desc:
'Enable the InfluxDB metrics'
...
@@ -117,7 +118,9 @@ module API
...
@@ -117,7 +118,9 @@ module API
:send_user_confirmation_email
,
:domain_whitelist
,
:domain_blacklist_enabled
,
:send_user_confirmation_email
,
:domain_whitelist
,
:domain_blacklist_enabled
,
:after_sign_up_text
,
:signin_enabled
,
:require_two_factor_authentication
,
:after_sign_up_text
,
:signin_enabled
,
:require_two_factor_authentication
,
:home_page_url
,
:after_sign_out_path
,
:sign_in_text
,
:help_page_text
,
:home_page_url
,
:after_sign_out_path
,
:sign_in_text
,
:help_page_text
,
:shared_runners_enabled
,
:max_artifacts_size
,
:max_pages_size
,
:container_registry_token_expire_delay
,
:shared_runners_enabled
,
:max_artifacts_size
,
:default_artifacts_expiration
,
:max_pages_size
,
:container_registry_token_expire_delay
,
:metrics_enabled
,
:sidekiq_throttling_enabled
,
:recaptcha_enabled
,
:metrics_enabled
,
:sidekiq_throttling_enabled
,
:recaptcha_enabled
,
:akismet_enabled
,
:admin_notification_email
,
:sentry_enabled
,
:akismet_enabled
,
:admin_notification_email
,
:sentry_enabled
,
:repository_storage
,
:repository_checks_enabled
,
:koding_enabled
,
:plantuml_enabled
,
:repository_storage
,
:repository_checks_enabled
,
:koding_enabled
,
:plantuml_enabled
,
...
...
lib/ci/api/builds.rb
View file @
d2d30cff
...
@@ -167,7 +167,7 @@ module Ci
...
@@ -167,7 +167,7 @@ module Ci
build
.
artifacts_file
=
artifacts
build
.
artifacts_file
=
artifacts
build
.
artifacts_metadata
=
metadata
build
.
artifacts_metadata
=
metadata
build
.
artifacts_expire_in
=
params
[
'expire_in'
]
build
.
set_artifacts_expire_in
(
params
[
'expire_in'
])
if
build
.
save
if
build
.
save
present
(
build
,
with:
Entities
::
BuildDetails
)
present
(
build
,
with:
Entities
::
BuildDetails
)
...
...
spec/models/ci/build_spec.rb
View file @
d2d30cff
...
@@ -161,7 +161,7 @@ describe Ci::Build, :models do
...
@@ -161,7 +161,7 @@ describe Ci::Build, :models do
is_expected
.
to
be_nil
is_expected
.
to
be_nil
end
end
it
'when res
se
ting value'
do
it
'when res
et
ting value'
do
build
.
artifacts_expire_in
=
nil
build
.
artifacts_expire_in
=
nil
is_expected
.
to
be_nil
is_expected
.
to
be_nil
...
...
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