Today I worked with a customer on a cross platform implementation of TFS. The intention is to use TFS for their java projects as well. One of the things we needed to arrange is the notion of so called snapshot builds and release builds. A snapshot build can be triggered by everyone and is allowed to be a build on the trunk or any other piece that needs to be validated, including a build of the tip of version control with a shelve set.
As a TFS adapt, I always thought that having this option to Build with a shelve set on the latest version of the sources is just awesome. I had never imagined that someone would like me to disable this option, still this is the question I got asked.
The reasoning behind this question is understandable. We created a build definition for a release build and this will, after a successful build, check in the results of the build into the Nexus repository. This will then trigger all sorts of other things in their organization, so we need to ensure that this build once triggered only can result in one thing and that is a stable release of sources already in a branch being checked by e.g another build. So one thing we needed to arrange is that only a few dedicated people are allowed to queue a release build. That was relatively easy, but they wanted me to ensure that no-one would ever be able to queue a release build with a shelve set. If you think of that this kind of makes sense, shelve set builds are ok for a snapshot build, but don’t make really sense for a release build if that is the way you set up your build definitions.
So this left me with the question how I would be able to disable this option?
It appears there is a solution to this in the build process template. Each build process template has a parameter called SupportedReasons. This enum is normally set to all, but you can also unselect the option ValidateShelveset, as shown in the picture below:
When you check in this modified template and then queue a build with a shelve set as shown below you will see we get an error message and I am prevented for queuing that build!
Of course it would be awesome if the UI had adapted to the fact that I unselected the Enum and it just did not show the option to queue a build with a shelve set. But it does prevent me from queuing a build with a shelve set and that is exactly what I needed.