Build Automation Using Jenkins and TFS Version Control
Build Automation Using Jenkins and TFS Version Control
Join the DZone community and get the full member experience.Join For Free
Can you release faster without sacrificing quality? See how with our free ebook Strategies for a Successful Test Automation Project and a free trial of Ranorex Studio today!
I’ve used several version control systems for my source code and research projects. Recently, I’ve consolidated them to TFS and Git. I have started using Visual Studio Online for my research work, CodePlex for my Open Source Frameworks and Tools and GitHub for my blog code. Much of these decisions are driven based on the target audience and the nature of my work (code). TFS, being an excellent ALM tool, offers more than just a version control system which can be particularly helpful when you are either having large teams to work with or have an open-source project whose build you would want to automate. For my research development (that happens at home), I was keen on build automation for CInject project.
Visual Studio Online offers a complete package of Continuous Integration and Delivery to Azure Services but there is no such feature for TFS repositories of CodePlex. For this case, I started evaluating other CI platforms like CruiseControl.NET, TeamCity and Jenkins. I zeroed down on Jenkins for its ease of use, extremely light-weight deployment, my familiarity with it and zero-dollar cost in setting it up.
For this example, we would use CodePlex repository, but the method can be used with any on-premise TFS repository or even with Visual Studio Online
Downloading the latest version
A direct link to Windows Version of Jenkins is available here. Installation of this will require administrative rights if you are doing it on Windows 7+, or Windows Server 2008+
Once the installation has been completed, you will have a service running in the Service Manager
If this service is running, you can access Jenkins console at: http://localhost:8080/
Download TFS Plugin
Visit the Manage Plugin Page [Manage Jenkins > Manage Plugins > Available ] (shortcut) and search for Team Foundation Server plugin. Click on the checkbox and press the button ‘Install without restart’
If your build machine/server has restricted access to the Internet, you will get an error downloading the file.
java.io.IOException: Failed to download from http://updates.jenkins-ci.org/download/plugins/tfs/3.1.1/tfs.hpi at hudson.model.UpdateCenter$UpdateCenterConfiguration.download(UpdateCenter.java:781) at hudson.model.UpdateCenter$DownloadJob._run(UpdateCenter.java:1125) at hudson.model.UpdateCenter$InstallationJob._run(UpdateCenter.java:1285) at hudson.model.UpdateCenter$DownloadJob.run(UpdateCenter.java:1103) at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at hudson.remoting.AtmostOneThreadExecutor$Worker.run(AtmostOneThreadExecutor.java:104) at java.lang.Thread.run(Unknown Source)
In such cases, you need to download latest version of the plugin manually and copy it to
You will need to restart Jenkins service if you had to install it manually.
Downloading Team Explorer Everywhere
If you are running this process on your desktop machine and you are a .NET developer, chances are that you would have Visual Studio 2012+ installed. In such cases, you will have Team Foundation executables on your machine and also the path of TF executables will be mentioned in PATH system variable as well.
When TF executable path is not part of PATH system variable, you will have to configure Jenkins to look into the right directory (shortcut). On my home laptop, I’ve configured it as,
If you are running this on your Windows Server which has only .NET framework installed, you will have to install TEE. If you are running this on a Unix/Linux server, you will still need TEE. This is a free executable from Microsoft and is very thin-client. You can download and install it from here and setup the configuration as
You would need to run tf eula on Command Prompt to accept the Agreement of Use and Terms and Conditions and press ‘y’ when it prompts. Similar configuration needs to be done for Unix / Linux. The same CMD file will work for Unix and Linux platforms.
Setting up TFS repository in Jenkins
Click on the New Job link on the left menu to create a new Build Profile (shortcut)
On the next screen, you can customize the configuration to enable concurrent builds, retry count, etc. But for this article, the focus would be to configure TFS workspace. So to get the TFS configuration, visit your CodePlex framework page and get the TFS URL. If you are configuring for a repository other than CodePlex, you can check the URL with your administrator
Copy the link to Jenkins as shown below and click on Apply
Now you can trigger Build for environment and it should build successfully.
You can use this method with any TFS repository – On-premise as well as Visual Studio Online. One thing worth noting here is – every TFS repository (here https://tfs.codeplex.com:443/tfs) has multiple collections (TFS01…. TFSxx) and each collection has projects. The Server URL should include the name of the collection, whereas the Project path should be a relative path ($/…)to the actual project.
Using CodePlex SVN Path with Jenkins
You can use SVN link to access the Codeplex repository as well. Please note that if you are using a non-Codeplex repository, you may not have a SVN URL.
So you can opt for any method if you are using Jenkins for CodePlex and can setup Build Automation and Continuous Integration as well.
Hope this helps.
Published at DZone with permission of Punit Ganshani , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.