In my system, I am downloading new build everyday in 1 folder and then use it for further causes but after running jenkins job I want to delete files in the folder (not workspace) which will delete specific folders from same directory. This will help me downloading new build every time based on different jenkins job running on same machine.
EG:
I am downloading x.x build and then running jenkins job on machine and then if I want to run other job which requires x.y build, it will just see if SOME build is already there in folder. if it is there, it will not download any kit after that. So, now simplest thing I can do is delete x.x after every jenkins run (post build ) so it will download x.y next time..
Please help. Thanks in advance
Navigate to /scriptApproval/ (Manage Jenkins > In-process Script Approval) and approve the script. File. delete works on master.
Locate the item you want to delete, highlight it by left-clicking the file or folder with your mouse once, and press the Delete key.
Delete views and folders - Jenkins Tutorial To delete a view, you would start by entering the view. And let's look at the build view for example. On the left-hand side, there is an option to delete view. So I'll click that and I'm prompted to confirm the deletion.
There's a lot you can break using the script console. Delete the builds' folders from disk (by default in $JENKINS_HOME/jobs/JobName/builds/ , using the start time stamp as folder name) and restart Jenkins, or Reload Configuration From Disk.
You can delete the whole folder using this syntax to delete a folder called bin
:
stage('Setup') {
steps {
dir ('bin') {
deleteDir()
}
}
}
If my understanding is right, consider my below assumptions
If your jenkins is running on a Unix server, then you can configure a post build step as suggested by nerdwaller above
rm -rf <<directoryname>>
Else, if your jenkins is running on a windows server, then select "execute batch command" from the build step and give the appropriate command like rmdir /Q /S nonemptydir
However, my best approach would be to use a platform independent tool like ant to delete the folders using Ant Delete Task and it can be configured similarly like the above two approaches instead selecting "invoke ant" in the build step/ post build step.
This will help you to achieve what you need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With