Blog

SPCAF + TeamCity = True

5 min read
5 min read

This is a guest blog post of Tobias Zimmergren, SharePoint Server MVP and founder of TOZIT AB, a consultancy in Sweden focusing on SharePoint, Office 365 and .NET technologies.

Securing code quality in SharePoint Apps and Solutions doesn’t have to be a manual task. Just as you can run SPCAF standalone, from Visual Studio or even integrated into your TFS Build – you can also integrate it very easily into any other build servers and ALM processes you’d like.

One particularly popular build environment that I’m using myself is TeamCity from Jetbrains. Since I’m also using SPCAF in all of my SharePoint and Office 365 development project, I wanted to integrate it into TeamCity.

The documentation talks about how to everything step-by-step.TeamCity

Integration with TeamCity made easy

There are several ways you can integrate SPCAF into your build environment. For example, one is MSBuild and another is PowerShell.

Since we use PowerShell both pre- and post-build in both development, testing and production environments and are essentially controlling our full ALM flow with PowerShell, it was a natural choice to integrate SPCAF into TeamCity using the SPCAF PowerShell Cmdlets.

We’ve prepared a sample PowerShell script for you

TeamCityPowerShellIf you’re interested in integrating SPCAF with TeamCity using PowerShell, see the documentation for a step-by-step guide and to download the files mentioned here. You will find a sample file called SPCAF.TeamCity.ps1 in the SPCAF PowerShell Cmdlet download, which you can start out with so you don’t have to write it all from scratch yourself.

This script accepts arguments that TeamCity can pass along when it’s executing the build. What happens with the passed parameters is up to you – but using this script as a base for your integration with TeamCity is a good start.

You don’t have to install SPCAF on the build server

SPCAF Server, as the name implies, is meant to run on the server for example in your build processes. You can however check-in the SPCAF PowerShell cmdlet into your source code system (TFS, Git, SVN, etc) – then when your build environment is performing a new fetch for sources then it will also download SPCAF directly from your source system.

This means that you don’t have to maintain the binaries for SPCAF Server on the build servers in case you have a few of those. You can simply update the SPCAF Server binaries in your source code system and check them in – then the next build will use the latest version of SPCAF automatically – on all your build servers!

I don’t want to be redundant in what I write. If the aforementioned integration sounds interesting, head on over to the How-to article and see how it can be done step-by-step.

Enjoy.

Summary and references

Subscribe to our newsletter