If you are making use of Visual Studio Team Services (VSTS) to manage your automated builds then you are likely already aware that completed builds are kept for a maximum of 10 days by default. You can increase the default up to 30 days but no longer (using TFS on premises gives you more control over the retention). If you want to keep your build artifacts longer than the maximum 30 days allowed, you must set the retention for the build to “keep forever”. There are some cases where it makes sense to automate this task – e.g. you’re calling out to a 3rd party deployment tool (e.g. Octopus Deploy) from your build definition and you want to set the retention to “keep forever” for production builds.
Adding to the VSTS-Tools Build Extensions published a few weeks ago, there is now a VSTS-Tools Keep build task that can be used to set the retention for a completed build to “keep forever”. This is an automated version of the VSTS-Keep command-line utility I wrote about previously.
VSTS-Keep
This extension allows you to set the retention for a specific build to Keep Forever.
- Target Branch – specifies the name of the branch that must be built in order for the task to run. For example, if you set the Target Branch to ‘master’ then the build will be set to keep forever only when the master branch is built.
- Execute on Debug Only – if checked, the task will execute only if system.debug is set to true.
Assuming the branch being built matches the Target Branch specified in the task settings, the resulting build will be set to “keep forever” as shown below:
There are other updates planned for this set of extensions. Check out the road map on the VSTS-Tools Build Extensions page for further details.
As always, if you have any suggestions, please let us know in the comments section below.
Install the VSTS-Tools Build Extensions here.
Also, you can check out the source code on GitHub here.