File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -90,12 +90,21 @@ def error(rc)
9090 " echo \" #{ branch_symlink_path } is not a symlink\" >&2'" )
9191error ( rc )
9292
93+ # cleanup old versions
94+
95+ rc = run ( "ssh #{ ssh_op } #{ host } 'find #{ host_path } -maxdepth 1 -type d -name \" #{ branch_dir } .*\" -printf \" %f\\ n\" | sort'" )
96+ error ( rc )
97+
9398builds = rc [ 0 ] . split
9499
95- exit ( 0 ) if builds . length <= 3
100+ puts "Total builds found: #{ builds . length } "
101+ puts "Builds: #{ builds . join ( "\n " ) } "
96102
97- builds = builds [ 0 ..- 3 ] # Keep two latest ones
103+ exit ( 0 ) if builds . length <= 2
98104
99- builds . each do |build |
100- run ( "ssh #{ ssh_op } #{ host } rm -rf #{ host_path } /#{ build } " )
105+ # List all builds except the two most recent
106+ old_builds = builds [ 0 ...-2 ]
107+ old_builds . each do |build |
108+ puts "Removing old build folder: #{ build } "
109+ run ( "ssh #{ ssh_op } #{ host } rm -rf #{ host_path } /#{ build } " )
101110end
You can’t perform that action at this time.
0 commit comments