Disclaimer: The statements and opinions expressed in this article are those of the author(s) and do not necessarily reflect the positions of Thoughtworks.
Li Jian (TWer in China office) took few days to write ruby code to clean the artifacts repository of Go automatically.
It is ruby code on google code (svn checkout http://cruisetools.googlecode.com/svn/trunk/ ). Anyone can check out to use.
You can run it to clean the artifacts under the artifacts folder. If some files/folders need to be kept, just put the relative path of files/folders in the file 'foldersToBeKept.txt' (One path in each line)
Then run the script 'rake dirname=/var/lib/cruise-server/logs/pipelines time=1w', it will delete all folders which are generated 1 week ago except for the folders in the kept list.
the param 'dirname' is the absolute path for the repository,
the param 'time' could be 1w, 2w, .... (means to delete the folders n weeks ago)
1m, 2m, .... (means to delete the folders n months ago)
2009-05-01 ... (meams to delete the folders before 2009-05-01)
you can run cron task to clean it. And our approach is following.
We setup a pipeline called 'cleanArtifacts' to clean the folder which is generated 1 week ago except for the ones in the list of folderToBeKept.txt.
And the job in this pipeline will be run by the agent which is running on the same box of Cruise server.
We only want to keep the important artifacts and get rid of others. So we setup a subversion repository say 'http://xx.xx.xx.xx:8080/svn/artifactsmanagement'. And only one file 'foldersToBeKept.txt' in the repository.
<pipeline name="cleanArtifacts">
<materials>
<svn url="http://cruisetools.googlecode.com/svn/trunk/artifactsmanagement/lib" dest="app" />
<svn url="http://xx.xx.xx.xx:8080/svn/artifactsmanagement/trunk" username="yyy" password="***" dest="keptfolder" />
</materials>
<stage name="defaultStage">
<jobs>
<job name="clean">
<tasks>
<exec command="/bin/bash" args="-c " cp foldersToBeKept.txt ../app"" workingdir="keptfolder" />
<rake target="dirname=/var/lib/cruise-server/logs/pipelines time=1w" workingdir="app" />
</tasks>
</job>
</jobs>
</stages>
</pipeline>
Disclaimer: The statements and opinions expressed in this article are those of the author(s) and do not necessarily reflect the positions of Thoughtworks.
Thoughtworks acknowledges the Traditional Owners of the land where we work and live, and their continued connection to Country. We pay our respects to Elders past and present. Aboriginal and Torres Strait Islander peoples were the world's first scientists, technologists, engineers and mathematicians. We celebrate the stories, culture and traditions of Aboriginal and Torres Strait Islander Elders of all communities who also work and live on this land.
As a company, we invite Thoughtworkers to be actively engaged in advancing reconciliation and strengthen their solidarity with the First Peoples of Australia. Since 2019, we have been working with Reconciliation Australia to formalize our commitment and take meaningful action to advance reconciliation. We invite you to review our Reconciliation Action Plan.