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
f205d099
Commit
f205d099
authored
Sep 19, 2018
by
Marin Jankovski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check delete and stop thresholds for cleanup
parent
9822dfd3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
scripts/review_apps/automated_cleanup.rb
scripts/review_apps/automated_cleanup.rb
+4
-3
No files found.
scripts/review_apps/automated_cleanup.rb
View file @
f205d099
...
...
@@ -37,7 +37,8 @@ class AutomatedCleanup
puts
"Checking for review apps not updated in the last
#{
days_for_stop
}
days..."
checked_environments
=
[]
threshold_day
=
threshold_time
(
days:
days_for_delete
)
delete_threshold
=
threshold_time
(
days:
days_for_delete
)
stop_threshold
=
threshold_time
(
days:
days_for_stop
)
gitlab
.
deployments
(
project_path
,
per_page:
50
).
auto_paginate
do
|
deployment
|
next
unless
deployment
.
environment
.
name
.
start_with?
(
'review/'
)
next
if
checked_environments
.
include?
(
deployment
.
environment
.
slug
)
...
...
@@ -47,11 +48,11 @@ class AutomatedCleanup
checked_environments
<<
deployment
.
environment
.
slug
deployed_at
=
Time
.
parse
(
deployment
.
created_at
)
if
deployed_at
<
threshold_day
if
deployed_at
<
delete_threshold
print_release_state
(
subject:
'Review app'
,
release_name:
deployment
.
environment
.
slug
,
release_date:
deployment
.
created_at
,
action:
'deleting'
)
gitlab
.
delete_environment
(
project_path
,
deployment
.
environment
.
id
)
cleaned_up_releases
<<
deployment
.
environment
.
slug
elsif
deployed_at
<
threshold_day
elsif
deployed_at
<
stop_threshold
print_release_state
(
subject:
'Review app'
,
release_name:
deployment
.
environment
.
slug
,
release_date:
deployment
.
created_at
,
action:
'stopping'
)
gitlab
.
stop_environment
(
project_path
,
deployment
.
environment
.
id
)
cleaned_up_releases
<<
deployment
.
environment
.
slug
...
...
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