How to remove old builds as scripted pipeline in a Jenkinsfile? Not only I fail to see the sexiness in this new approach, but also I dislike the groovy syntax. In the end add I came up with several solutions to accomplish my goal: Keep only the last 10 builds. There are several ways and solutions. It was a huge try and error approach.