Skip to content

Commit

Permalink
ansible: automatic clean-up of binary_tmp repo
Browse files Browse the repository at this point in the history
PR-URL: #1515
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
  • Loading branch information
joaocgreis committed Dec 6, 2018
1 parent bd5a1fc commit 5961359
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
17 changes: 17 additions & 0 deletions ansible/roles/jenkins-workspace/files/clean_binary_tmp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash -ex

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='7 days ago' -s $b)" ]; then
(git branch -D $b |& tee -a ~binary_tmp/clean_binary_tmp.log) || true
fi
done

git prune

du -sh ~binary_tmp/binary_tmp.git/ >> ~binary_tmp/clean_binary_tmp.log
19 changes: 19 additions & 0 deletions ansible/roles/jenkins-workspace/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,22 @@
line: "MaxStartups 100:30:150"
dest: "{{ ssh_config }}"
regexp: "MaxStartups"

- name: Create clean-up script
copy:
src: "{{ role_path }}/files/clean_binary_tmp.sh"
dest: "~binary_tmp/clean_binary_tmp.sh"
owner: "binary_tmp"
group: "binary_tmp"
mode: 0755

- name: Schedule clean-up script to run daily
lineinfile:
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 5961359

Please sign in to comment.