Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
eede4ab1
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
eede4ab1
编写于
2月 16, 2017
作者:
L
Lin Jen-Shin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
0 for unlimited, disallow blank, feedback:
https://gitlab.com/gitlab-org/gitlab-ce/issues/27762#note_23520780
上级
37cc3aae
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
36 addition
and
35 deletion
+36
-35
app/models/application_setting.rb
app/models/application_setting.rb
+4
-12
app/models/ci/build.rb
app/models/ci/build.rb
+1
-1
app/views/admin/application_settings/_form.html.haml
app/views/admin/application_settings/_form.html.haml
+3
-2
db/migrate/20170214084746_add_default_artifacts_expiration_to_application_settings.rb
...d_default_artifacts_expiration_to_application_settings.rb
+2
-2
db/schema.rb
db/schema.rb
+2
-2
doc/user/admin_area/settings/continuous_integration.md
doc/user/admin_area/settings/continuous_integration.md
+4
-4
spec/models/application_setting_spec.rb
spec/models/application_setting_spec.rb
+14
-12
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+6
-0
未找到文件。
app/models/application_setting.rb
浏览文件 @
eede4ab1
...
...
@@ -269,14 +269,6 @@ class ApplicationSetting < ActiveRecord::Base
self
.
repository_storages
=
[
value
]
end
def
default_artifacts_expire_in
=
(
value
)
if
value
.
present?
super
(
value
.
squish
)
else
super
(
nil
)
end
end
# Choose one of the available repository storage options. Currently all have
# equal weighting.
def
pick_repository_storage
...
...
@@ -306,10 +298,10 @@ class ApplicationSetting < ActiveRecord::Base
end
def
check_default_artifacts_expire_in
if
default_artifacts_expire_in
&&
ChronicDuration
.
parse
(
default_artifacts_expire_in
).
nil?
errors
.
add
(
:default_artifacts_expiration
,
"can't be 0. Leave it blank for no expiration"
)
if
default_artifacts_expire_in
.
blank?
errors
.
add
(
:default_artifacts_expiration
,
"is not presented"
)
else
ChronicDuration
.
parse
(
default_artifacts_expire_in
)
end
rescue
ChronicDuration
::
DurationParseError
errors
.
add
(
:default_artifacts_expiration
,
"is invalid"
)
...
...
app/models/ci/build.rb
浏览文件 @
eede4ab1
...
...
@@ -509,7 +509,7 @@ module Ci
def
artifacts_expire_in
=
(
value
)
self
.
artifacts_expire_at
=
if
value
Time
.
now
+
ChronicDuration
.
parse
(
value
)
ChronicDuration
.
parse
(
value
)
&
.
seconds
&
.
from_now
end
end
...
...
app/views/admin/application_settings/_form.html.haml
浏览文件 @
eede4ab1
...
...
@@ -219,10 +219,11 @@
.col-sm-10
=
f
.
text_field
:default_artifacts_expire_in
,
class:
'form-control'
.help-block
Set the default expiration time for each job's artifacts
Set the default expiration time for each job's artifacts.
0 for unlimited.
=
surround
'('
,
')'
do
=
link_to
'syntax'
,
help_page_path
(
'ci/yaml/README'
,
anchor:
'artifactsexpire_in'
)
=
link_to
icon
(
'question-circle'
),
help_page_path
(
'user/admin_area/settings/continuous_integration'
,
anchor:
'default-artifacts-expiration
-time
'
)
=
link_to
icon
(
'question-circle'
),
help_page_path
(
'user/admin_area/settings/continuous_integration'
,
anchor:
'default-artifacts-expiration'
)
-
if
Gitlab
.
config
.
registry
.
enabled
%fieldset
...
...
db/migrate/20170214084746_add_default_artifacts_expiration_to_application_settings.rb
浏览文件 @
eede4ab1
...
...
@@ -5,7 +5,7 @@ class AddDefaultArtifactsExpirationToApplicationSettings < ActiveRecord::Migrati
def
change
add_column
:application_settings
,
:default_artifacts_expire_in
,
:string
,
null:
true
:default_artifacts_expire_in
,
:string
,
null:
false
,
default:
'0'
end
end
db/schema.rb
浏览文件 @
eede4ab1
...
...
@@ -111,7 +111,7 @@ ActiveRecord::Schema.define(version: 20170214111112) do
t
.
boolean
"plantuml_enabled"
t
.
integer
"max_pages_size"
,
default:
100
,
null:
false
t
.
integer
"terminal_max_session_time"
,
default:
0
,
null:
false
t
.
string
"default_artifacts_expire_in"
,
limit:
255
t
.
string
"default_artifacts_expire_in"
,
default:
'0'
,
null:
false
end
create_table
"audit_events"
,
force: :cascade
do
|
t
|
...
...
@@ -1352,4 +1352,4 @@ ActiveRecord::Schema.define(version: 20170214111112) do
add_foreign_key
"timelogs"
,
"merge_requests"
,
name:
"fk_timelogs_merge_requests_merge_request_id"
,
on_delete: :cascade
add_foreign_key
"trending_projects"
,
"projects"
,
on_delete: :cascade
add_foreign_key
"u2f_registrations"
,
"users"
end
\ No newline at end of file
end
doc/user/admin_area/settings/continuous_integration.md
浏览文件 @
eede4ab1
...
...
@@ -18,13 +18,13 @@ that this setting is set for each job.
[
art-yml
]:
../../../administration/build_artifacts
## Default artifacts expiration
time
## Default artifacts expiration
The default expiration time of the
[
build
artifacts
][
art-yml
]
can be set in
The default expiration time of the
[
job
artifacts
][
art-yml
]
can be set in
the Admin area of your GitLab instance. The syntax of duration is described
in
[
artifacts:expire_in
][
duration-syntax
]
. The default is
`30 days`
. Note that
this setting is set for each job.
Leave it blank if you don't want to se
t
default expiration time
.
this setting is set for each job.
Set it to 0 if you don't want defaul
t
expiration
.
1.
Go to
**Admin area > Settings**
(
`/admin/application_settings`
).
...
...
spec/models/application_setting_spec.rb
浏览文件 @
eede4ab1
...
...
@@ -30,20 +30,16 @@ describe ApplicationSetting, models: true do
end
describe
'default_artifacts_expire_in'
do
it
'sets an error if it
is invalid
'
do
it
'sets an error if it
cannot parse
'
do
setting
.
update
(
default_artifacts_expire_in:
'a'
)
expect
(
setting
).
to
be_invalid
expect
(
setting
.
errors
.
messages
)
.
to
have_key
(
:default_artifacts_expiration
)
expect_invalid
end
it
'
does not allow 0
'
do
setting
.
update
(
default_artifacts_expire_in:
'
0
'
)
it
'
sets an error if it is blank
'
do
setting
.
update
(
default_artifacts_expire_in:
'
'
)
expect
(
setting
).
to
be_invalid
expect
(
setting
.
errors
.
messages
)
.
to
have_key
(
:default_artifacts_expiration
)
expect_invalid
end
it
'sets the value if it is valid'
do
...
...
@@ -53,11 +49,17 @@ describe ApplicationSetting, models: true do
expect
(
setting
.
default_artifacts_expire_in
).
to
eq
(
'30 days'
)
end
it
'
does not set it if it is blank
'
do
setting
.
update
(
default_artifacts_expire_in:
'
'
)
it
'
sets the value if it is 0
'
do
setting
.
update
(
default_artifacts_expire_in:
'
0
'
)
expect
(
setting
).
to
be_valid
expect
(
setting
.
default_artifacts_expire_in
).
to
be_nil
expect
(
setting
.
default_artifacts_expire_in
).
to
eq
(
'0'
)
end
def
expect_invalid
expect
(
setting
).
to
be_invalid
expect
(
setting
.
errors
.
messages
)
.
to
have_key
(
:default_artifacts_expiration
)
end
end
...
...
spec/models/ci/build_spec.rb
浏览文件 @
eede4ab1
...
...
@@ -166,6 +166,12 @@ describe Ci::Build, :models do
is_expected
.
to
be_nil
end
it
'when setting to 0'
do
build
.
artifacts_expire_in
=
'0'
is_expected
.
to
be_nil
end
end
describe
'#commit'
do
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录