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.

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.

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.

Click the "Push" menu will push the code change to TFS then.

Configure Jenkins

Create a freestyle project in Jenkins shown below.

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.

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.

In the Service page, select Jenkins.

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.

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.

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.

Comments (4)

  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.

  4. @Wu Shai, I do get this error

    Repository URL
    Help for feature: Repository URL
    HTTP ERROR 403
    Problem accessing /job/TFS/descriptorByName/hudson.plugins.git.UserRemoteConfig/checkUrl. Reason:

    No valid crumb was included in the request

    after giving the tfs url in git…how do i give the password? by default it shows jenkins password or it show none

    how do i give tfs password?

    can you give more details on this

    Thanks in advance

Skip to main content