This post is about getting the latest code from TFS hosted in cloud not on premise. It’s applicable to a TFVS repository not to a Git repository.
Getting the latest version from VisualStudio.COM (aka. Visual Studio Online) doesn’t work with the traditional TF.EXE. Reason for that is that tf.exe doesn’t support VSO login dialog. Which makes impossible to use your Windows ID credentials, unless they are already cached in your Team Explorer or Visual Studio.
This can be done at this point using Team Explorer Everywhere for Team Foundation Server. For this example I’m using version TEE-CLC-12.0.2.
Team Explorer Everywhere
Download this package into a folder on your machine. Once you are done, you will see tf.cmd which is the replacement for tf.exe .
Add this location to your environment Path under System variables section.
Configure your Jenkins instance
As a prerequisite, you need to have already a Jenkins instance, up and running.
Go to Manage Jenkins > Manage Plugins. Switch to Available tab and search and install the following two plugins:
- Team Foundation Server Plug-in
- MSBuild Plugin
Configure Team Foundation Server Plug-in
Team Foundation Server plugin is using by default tf.exe. We need to change this configuration to point the location where you’ve unpacked Team Explorer Everywhere.
Go to Manage Jenkins > Configure System and scroll down until you find Team Foundation Server section. Update the path there.
Configure MSBuild plugin
This plugin is responsible for calling msbuild.exe.
Go to Manage Jenkins > Configure System and scroll down until you find MSBuild section.
Create Jenkins project
Navigate to Jenkins home page, choose New Item, pick Freestyle project and provide the Item name field.
Important: Running TFEE for the first time will ask you to accept the End User License Agreement. This command must be run from the context of your workspace per this project. Just before setting up the source control settings we need to run: tf eula –accept.
Accepting TF eula
Under the Build section and a new Execute Windows batch step.
Note: If you’ve change the environment Path property, you need to restart the Jenkins service. If you don’t, will continue to say that it doesn’t know about tf.cmd.
Save the project and run the job. You should get a result in console saying that you’ve accepted the EULA.
You can now remove previous added step, because EULA is now accepted.
Configure Source Control Management
Scrolling down in the configuration page for this project, you will get to Source Code Management section.
VERY IMPORTANT: For login name you MUST use Window Live ID, but you MUST have also alternate credentials activated – don’t use them.
Login name: firstname.lastname@example.org
User password: yourliveidpassword
At this point everything should work as expected.
Adding the build step
Go back to the projects/job list and select TFVS demo. Choose to configure this project. Scroll to the Build section and add a new step called “Build a Visual Studio project or solution using MSBuild”.
Depending on how your file/directory structure is, you have to provide the solution path relative to workspace.
And the result is:
Feel free to contact me. I’m eager to know if this helped you or if your are having troubles in applying this steps.