Jenkins delete builds older than latest 20 builds for all jobs
<p>I am in the process of cleaning up Jenkins (it was setup incorrectly) and I need to delete builds that are older than the latest 20 builds for every job.</p>

<p>Is there any way to automate this using a script or something?</p>

<p>I found many solutions to delete certain builds for specific jobs, but I can't seem to find anything for all jobs at once.</p>

<p>Any help is much appreciated.</p>