Custom build result pruner

Out of the box, RTC allows you to specify a basic pruning policy for your build definitions. You can indicate how many of your most recent successful and failed build results you’d like to keep, and periodically the other older build results will be deleted. You may quickly find that you require a more sophisticated approach to build result pruning. That’s where this blog comes in.

I’ve created a sample custom pruner that will hopefully show you how you can use some of the various team build APIs to create your own pruner, and ideally you can use some of my code as a starting point. This is a plain java application, and I swiped the code and setup instructions from Ralph Schoon’s article Automated Build Output Management Using the Plain Java Client Libraries to use as my own starting point.

My pruner contains three classes:

  • BuildResultQueryer: I’m pretty sure queryer is not a word, but this class queries for all of the build results that we’d like to consider for pruning. You can query based on age, state, and status, and you can choose to exclude personal builds from pruning (but by default they are included). You’ll see in the comments that some nice future enhancements might include querying on more than one state, more than one status, and including or excluding based on tags.
  • BuildResultPruner: This class was written to work specifically with our dependency builds, and is where you would likely make your own modifications. It takes a list of build results and checks to see if there are any successful translator outputs. If there are, the failed listings are removed. If there aren’t, the entire build result is deleted. Take a look at the prune() method to re-purpose this tool for your needs.
  • BuildResultPrunerTool: This is the main entry point into the tool. It takes a configuration properties file as an argument, and you can also override the repository address, user id, password, and build definition name. This class connects to the repository and then invokes the queryer and pruner in turn.

I’m sharing both the jar in case you want to try this tool as-is and the source so you can tweak this to work to your own specifications. I’m also sharing my configuration properties file as an example. If you’re not pulling the project into eclipse and running it there, you can invoke it like so from the command line:

java -cp C:/tmp/export/BuildResultPrunerTool.jar;C:/RTC3013Dev/RTC-Client-plainJavaLib-* -config C:\

Notice that I have the RTC plain java client libraries in my classpath (per Ralph’s article mentioned above). Ralph also talks about how you could use an RTC command line build to run your plain java application on a schedule, which would make good sense for your custom build result pruner.

Remember that this code comes with the usual lack of promise or guarantee. Enjoy!

This entry was posted in Rational Team Concert. Bookmark the permalink.

2 Responses to Custom build result pruner

  1. Ralph Schoon says:

    Thanks for enhancing my code Robin. Great that you added the query tool, that is really interesting for other areas of the API as well. I will shamelessly reuse it for my own purposes!

  2. Pingback: Build Artifacts Publishing and Automated Build Output Management Using the Plain Java Client Libraries | rsjazz

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s