TFS and Jenkins Integration


As soon as there is a new code submit to TFS, TFS can notify Jenkins to perform continuous integration build or test. This is effective for unit test as we always would like to trigger unit test to check whether there is any code regression. This blog will cover:

  • How to create the project in TFS.
  • How to submit code change from Visual Studio Code.
  • How to trigger the continuous integration from TFS to Jenkins.

Create Project from TFS

In TFS 2015 Update 3, you are able to click the “New team project” button to create a new project shown below. Let’s choose Git as the source control.
12-1

Setup Visual Studio Code

Get the Git repository address of the project just created, clone the project to development machine shown below. Also, it is needed to git config the user name and email.
12-3


Open the local Git repository in Visual Studio Code and can make any code change and submit now. Visual Studio Code will notice the code chang automatically. Click the “commit All” button will commit the change to local git.
12-4


Click the “Push” menu will push the code change to TFS then.
12-5

Configure Jenkins

Create a freestyle project in Jenkins shown below.
12-6


In the Configuration of the newly created project, select Git as the repository of Source Code Management. Both of the Git repository address and a TFS credential are needed shown below.
12-12

Configure TFS

Open the team project administrator page in TFS web portal, there is one tab named “Service Hooks”. It supports multiple services not only for continuous integration. Add a new service.
12-7


In the Service page, select Jenkins.
12-8


In the Trigger page, select “Code pushed” which means TFS will notify Jenkins as soon as there is new code change. You can also select “Build completed” if TFS performs a scheduled build by build definition.
12-9


In the Action page, provide the project name which is just created in Jenkins. Both of API token and password are supported and token is recommended.
12-10


Before finishing the configuration, it is suggested to click the “Test” button in the Action page to make sure everything is working fine. If there is 403 error shown below, uncheck “Prevent Cross Site Request Forgery exploits” in Jenkins “Configure Global Security” management portal, and try again.
12-11

Comments (3)

  1. Jerry.liu says:

    Great post! Easy understanding in such a step by step guide

  2. Fetigue says:

    Thanks for the post! do you have any step by step for TFS as version control rather than git ?

  3. Wu Shuai says:

    @Fetigue, in Source Code Management, there is “Team Foundation Version Control(TFVC)” option for version control.

Skip to main content