I am new to docker and jenkins. However ultimately I am creating a job in jenkins so that I can delete the volume cache of gitlab-runner which is stored in our linux machines (CentOS7)
To achieve this, I am creating a periodic job every 6 hours with the following command in jenkins:
docker volume prune -f
However it doesn't clean up the space at all. This is the output of jenkins job :
Started by timer
Running as SYSTEM
Building remotely on buildbng17 (gitlab) in workspace /mnt/data0/jenkins/workspace/gitlab-cleanup
[WS-CLEANUP] Deleting project workspace...
[WS-CLEANUP] Deferred wipeout is used...
[WS-CLEANUP] Done
[gitlab-cleanup] $ /bin/sh -xe /tmp/jenkins3799570002967825583.sh
+ find /mnt/data0/gitlab/data/backups/ -name '*.tgz' -mtime +30
/mnt/data0/gitlab/data/backups/etc-gitlab-1611415968.tgz
Started calculate disk usage of build
Finished Calculation of disk usage of build in 0 seconds
Started calculate disk usage of workspace
Finished Calculation of disk usage of workspace in 0 seconds
Finished: SUCCESS
When I went to my buildbng17 machine and checked if there is any volume their, so there was volume which I had to clean up by performing
docker volume prune
The only drawback is that I need to do it manually and give that "y" when it asks for confirmation. And the data gets clean.
What command should I give in jenkins so that it will automatically clean up the volume without asking for confirmation? (because docker volume prune -f is not working)
I even tried to run the docker volume prune -f command manually in my linux machine, it still doesn't clean up the volume and shows 0kb freed up (However there is the volume which I checked from docker volume ls)
Is there any better approach we can do to automate it inside gitlab-runner itself ? Or some better feature of jenkins or docker of which I am not aware of?
The gitlab-runner keeps on running and covers the diskspace.
One more thing : We are using Gitlab and Gitlab-runner on docker.
Thanks in advance, Sameer