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
iv
gitlab-ce
Commits
ffe8dbde
Commit
ffe8dbde
authored
Jun 08, 2016
by
Kamil Trzcinski
Committed by
Phil Hughes
Jun 13, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move keep to ArtifactsController
parent
aea4041c
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
27 additions
and
20 deletions
+27
-20
app/controllers/projects/artifacts_controller.rb
app/controllers/projects/artifacts_controller.rb
+5
-0
app/models/ci/build.rb
app/models/ci/build.rb
+4
-4
app/views/projects/builds/_sidebar.html.haml
app/views/projects/builds/_sidebar.html.haml
+10
-9
app/workers/expire_build_artifacts_worker.rb
app/workers/expire_build_artifacts_worker.rb
+2
-1
config/gitlab.yml.example
config/gitlab.yml.example
+2
-2
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+3
-3
config/routes.rb
config/routes.rb
+1
-1
No files found.
app/controllers/projects/artifacts_controller.rb
View file @
ffe8dbde
...
@@ -34,6 +34,11 @@ class Projects::ArtifactsController < Projects::ApplicationController
...
@@ -34,6 +34,11 @@ class Projects::ArtifactsController < Projects::ApplicationController
end
end
end
end
def
keep
build
.
keep_artifacts!
redirect_to
namespace_project_build_path
(
project
.
namespace
,
project
,
build
)
end
private
private
def
build
def
build
...
...
app/models/ci/build.rb
View file @
ffe8dbde
...
@@ -12,7 +12,7 @@ module Ci
...
@@ -12,7 +12,7 @@ module Ci
scope
:unstarted
,
->
()
{
where
(
runner_id:
nil
)
}
scope
:unstarted
,
->
()
{
where
(
runner_id:
nil
)
}
scope
:ignore_failures
,
->
()
{
where
(
allow_failure:
false
)
}
scope
:ignore_failures
,
->
()
{
where
(
allow_failure:
false
)
}
scope
:with_artifacts
,
->
()
{
where
.
not
(
artifacts_file:
nil
)
}
scope
:with_artifacts
,
->
()
{
where
.
not
(
artifacts_file:
nil
)
}
scope
:with_
artifacts_expired
,
->
()
{
with_artifacts
.
where
(
'artifacts_expire_at < ?'
,
Time
.
now
)
}
scope
:with_
expired_artifacts
,
->
()
{
with_artifacts
.
where
(
'artifacts_expire_at < ?'
,
Time
.
now
)
}
mount_uploader
:artifacts_file
,
ArtifactUploader
mount_uploader
:artifacts_file
,
ArtifactUploader
mount_uploader
:artifacts_metadata
,
ArtifactUploader
mount_uploader
:artifacts_metadata
,
ArtifactUploader
...
@@ -352,10 +352,10 @@ module Ci
...
@@ -352,10 +352,10 @@ module Ci
end
end
def
artifacts_expired?
def
artifacts_expired?
self
.
artifacts_expire_at
<
Time
.
now
&&
!
artifacts?
!
artifacts?
&&
artifacts_expire_at
&&
artifacts_expire_at
<
Time
.
now
end
end
def
keep_artifacts
def
keep_artifacts
!
self
.
update
(
artifacts_expire_at:
nil
)
self
.
update
(
artifacts_expire_at:
nil
)
end
end
...
@@ -366,7 +366,7 @@ module Ci
...
@@ -366,7 +366,7 @@ module Ci
end
end
def
update_erased!
(
user
=
nil
)
def
update_erased!
(
user
=
nil
)
self
.
update
(
erased_by:
user
,
erased_at:
Time
.
now
)
self
.
update
(
erased_by:
user
,
erased_at:
Time
.
now
,
artifacts_expire_at:
nil
)
end
end
def
yaml_variables
def
yaml_variables
...
...
app/views/projects/builds/_sidebar.html.haml
View file @
ffe8dbde
...
@@ -44,15 +44,16 @@
...
@@ -44,15 +44,16 @@
%p
.build-detail-row
%p
.build-detail-row
%span
.build-light-text
Erased:
%span
.build-light-text
Erased:
#{
time_ago_with_tooltip
(
@build
.
erased_at
)
}
#{
time_ago_with_tooltip
(
@build
.
erased_at
)
}
-
elsif
@build
.
artifacts_expired?
-
else
%p
.build-detail-row.artifacts-expired.alert.alert-warning
-
if
@build
.
artifacts_expired?
The artifacts were removed
#{
time_ago_with_tooltip
(
@build
.
artifacts_expire_at
)
}
.artifacts-expired.alert.alert-warning
-
elsif
@build
.
artifacts_expire_at
The artifacts were removed
#{
time_ago_with_tooltip
(
@build
.
artifacts_expire_at
)
}
%p
.build-detail-row.artifacts-expired.alert.alert-info
-
elsif
@build
.
artifacts_expire_at
The artifacts will be removed at
#{
time_ago_with_tooltip
(
@build
.
artifacts_expire_at
)
}
.artifacts-expired.alert.alert-warning
.pull-right
The artifacts will be removed in
#{
duration_in_words
(
@build
.
artifacts_expire_at
,
Time
.
now
)
}
=
link_to
keep_artifacts_namespace_project_build_artifacts_path
(
@project
.
namespace
,
@project
,
@build
),
class:
'btn btn-sm btn-primary'
do
.pull-right
Keep
=
link_to
keep_namespace_project_build_artifacts_path
(
@project
.
namespace
,
@project
,
@build
),
class:
'btn btn-xs btn-primary'
,
method: :post
do
Keep
%p
.build-detail-row
%p
.build-detail-row
%span
.build-light-text
Runner:
%span
.build-light-text
Runner:
-
if
@build
.
runner
&&
current_user
&&
current_user
.
admin
-
if
@build
.
runner
&&
current_user
&&
current_user
.
admin
...
...
app/workers/expire_build_artifacts.rb
→
app/workers/expire_build_artifacts
_worker
.rb
View file @
ffe8dbde
...
@@ -4,8 +4,9 @@ class ExpireBuildArtifacts
...
@@ -4,8 +4,9 @@ class ExpireBuildArtifacts
def
perform
def
perform
Rails
.
logger
.
info
'Cleaning old build artifacts'
Rails
.
logger
.
info
'Cleaning old build artifacts'
builds
=
Ci
::
Build
.
with_
artifacts_expired
builds
=
Ci
::
Build
.
with_
expired_artifacts
builds
.
find_each
(
batch_size:
50
).
each
do
|
build
|
builds
.
find_each
(
batch_size:
50
).
each
do
|
build
|
Rails
.
logger
.
debug
"Removing artifacts build
#{
build
.
id
}
..."
build
.
erase_artifacts!
build
.
erase_artifacts!
end
end
end
end
...
...
config/gitlab.yml.example
View file @
ffe8dbde
...
@@ -164,8 +164,8 @@ production: &base
...
@@ -164,8 +164,8 @@ production: &base
# Flag stuck CI builds as failed
# Flag stuck CI builds as failed
stuck_ci_builds_worker:
stuck_ci_builds_worker:
cron: "0 0 * * *"
cron: "0 0 * * *"
# Remove
o
ld artifacts
# Remove
expired bui
ld artifacts
expire_build_artifacts:
expire_build_artifacts
_worker
:
cron: "50 * * * *"
cron: "50 * * * *"
# Periodically run 'git fsck' on all repositories. If started more than
# Periodically run 'git fsck' on all repositories. If started more than
# once per hour you will have concurrent 'git fsck' jobs.
# once per hour you will have concurrent 'git fsck' jobs.
...
...
config/initializers/1_settings.rb
View file @
ffe8dbde
...
@@ -279,9 +279,9 @@ Settings['cron_jobs'] ||= Settingslogic.new({})
...
@@ -279,9 +279,9 @@ Settings['cron_jobs'] ||= Settingslogic.new({})
Settings
.
cron_jobs
[
'stuck_ci_builds_worker'
]
||=
Settingslogic
.
new
({})
Settings
.
cron_jobs
[
'stuck_ci_builds_worker'
]
||=
Settingslogic
.
new
({})
Settings
.
cron_jobs
[
'stuck_ci_builds_worker'
][
'cron'
]
||=
'0 0 * * *'
Settings
.
cron_jobs
[
'stuck_ci_builds_worker'
][
'cron'
]
||=
'0 0 * * *'
Settings
.
cron_jobs
[
'stuck_ci_builds_worker'
][
'job_class'
]
=
'StuckCiBuildsWorker'
Settings
.
cron_jobs
[
'stuck_ci_builds_worker'
][
'job_class'
]
=
'StuckCiBuildsWorker'
Settings
.
cron_jobs
[
'expire_build_artifacts'
]
||=
Settingslogic
.
new
({})
Settings
.
cron_jobs
[
'expire_build_artifacts
_worker
'
]
||=
Settingslogic
.
new
({})
Settings
.
cron_jobs
[
'expire_build_artifacts'
][
'cron'
]
||=
'0 0 * * *'
Settings
.
cron_jobs
[
'expire_build_artifacts
_worker
'
][
'cron'
]
||=
'0 0 * * *'
Settings
.
cron_jobs
[
'expire_build_artifacts
'
][
'job_class'
]
=
'ExpireBuildArtifacts
'
Settings
.
cron_jobs
[
'expire_build_artifacts
_worker'
][
'job_class'
]
=
'ExpireBuildArtifactsWorker
'
Settings
.
cron_jobs
[
'repository_check_worker'
]
||=
Settingslogic
.
new
({})
Settings
.
cron_jobs
[
'repository_check_worker'
]
||=
Settingslogic
.
new
({})
Settings
.
cron_jobs
[
'repository_check_worker'
][
'cron'
]
||=
'20 * * * *'
Settings
.
cron_jobs
[
'repository_check_worker'
][
'cron'
]
||=
'20 * * * *'
Settings
.
cron_jobs
[
'repository_check_worker'
][
'job_class'
]
=
'RepositoryCheck::BatchWorker'
Settings
.
cron_jobs
[
'repository_check_worker'
][
'job_class'
]
=
'RepositoryCheck::BatchWorker'
...
...
config/routes.rb
View file @
ffe8dbde
...
@@ -714,7 +714,6 @@ Rails.application.routes.draw do
...
@@ -714,7 +714,6 @@ Rails.application.routes.draw do
post
:cancel
post
:cancel
post
:retry
post
:retry
post
:erase
post
:erase
post
:keep_artifacts
get
:trace
get
:trace
get
:raw
get
:raw
end
end
...
@@ -723,6 +722,7 @@ Rails.application.routes.draw do
...
@@ -723,6 +722,7 @@ Rails.application.routes.draw do
get
:download
get
:download
get
:browse
,
path:
'browse(/*path)'
,
format:
false
get
:browse
,
path:
'browse(/*path)'
,
format:
false
get
:file
,
path:
'file/*path'
,
format:
false
get
:file
,
path:
'file/*path'
,
format:
false
post
:keep
end
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