Skip to content

Commit

Permalink
fixup! ansible: automatic clean-up of binary_tmp repo
Browse files Browse the repository at this point in the history
  • Loading branch information
joaocgreis committed Dec 1, 2018
1 parent c0a483f commit 9b6f4b0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions ansible/roles/jenkins-workspace/files/clean_binary_tmp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

cd ~binary_tmp/binary_tmp.git
(echo; date) >> ~binary_tmp/clean_binary_tmp.log
du -sh ~binary_tmp/binary_tmp.git/ >> ~binary_tmp/clean_binary_tmp.log

git fetch origin +master:master

for b in $(git branch | sed /\*/d); do
if [ -z "$(git log -1 --since='4 weeks ago' -s $b)" ]; then
(git branch -D $b || true) |& tee -a ~binary_tmp/clean_binary_tmp.log
if [ -z "$(git log -1 --since='7 days ago' -s $b)" ]; then
(git branch -D $b |& tee -a ~binary_tmp/clean_binary_tmp.log) || true
fi
done

Expand Down
9 changes: 7 additions & 2 deletions ansible/roles/jenkins-workspace/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,13 @@
group: "binary_tmp"
mode: 0755

- name: Schedule clean-up script to run weekly
- name: Schedule clean-up script to run daily
lineinfile:
line: "0 5 * * 0 binary_tmp ~binary_tmp/clean_binary_tmp.sh"
line: "0 5 * * * binary_tmp ~binary_tmp/clean_binary_tmp.sh"
dest: "/etc/crontab"
regexp: "clean_binary_tmp"

- name: Disable automatic garbage collection
command: "git config gc.auto 0"
args:
chdir: "~binary_tmp/binary_tmp.git/"

0 comments on commit 9b6f4b0

Please sign in to comment.