A Jenkins plugin which allows to perform rotation of build history with low memory pressure.
The reason we created this plugin is because we found the default rotation in Jenkins to use a lot of memory. In our case 25% percent of memory footprint was related to job history rotation alone. This is caused by an implementation detail of the default implementation: It guarantees that if you want to keep only last X builds in history, it would keep exactly X builds. The main idea of this plugin is to make a little bit different guarantee: If you want to keep only last X builds in history, it would keep a maximum of X builds.
Here are some examples to illustrate the difference.
Let us assume that we have 5 builds in history and we want to keep 5 builds:
- build1
- build2
- build3
- build4
- build5
After that you want to remove build3
, because it is broken. So, now you have only:
- build1
- build2
- build4
- build5
And after build6
just finished:
- build1
- build2
- build4
- build5
- build6
The Log Rotator
strategy in this case would load the entire history in memory to check whether there are 5 builds in reality or not, and it would not delete anything at the end. As a result the list would be the same:
- build1
- build2
- build4
- build5
- build6
The Build Rotator
is checking only the difference between last build number and the number of builds it should keep. And if it's more than 5, it would remove the first build. So, afterwards you would have:
- build2
- build4
- build5
- build6
More importantly, Build Rotator
respects all other aspects of rotation in same way as the Log Rotator
strategy. IN particular, it does not remove:
- Builds that have "Keep log" enabled.
- The "Last successful build" in the history.
- The "Last stable build" in the history.
- An ongoing build.
Prerequisites:
- JDK 7 (or above)
- Apache Maven
Build process is quite simple:
mvn install
To get started:
- Install the plugin.
- Go to the Jenkins Configuration.
- Enable on "Discard Old Builds".
- Set the "Build Rotator" strategy.
Alexander Akbashev - [email protected]
Licensed under the MIT License (MIT).