Setting up CI/CD with the TFS Plugin for Jenkins

Today I am going to show you how to configure Jenkins with VSTS using the TFS Plugin for Jenkins. Using this plugin makes it very easy to use Jenkins with VSTS to create a full CI/CD pipeline.

I do not cover installing Jenkins or any details. I assume that if you are reading this you already know how to use Jenkins.  If you are new to CI/CD just use VSTS it requires no installation and you can build Java, Node.js, .Net out of the box. If you are already using Jenkins I will show you how to wire it to VSTS.

You are going to need the following

With the above we are ready to configure a project to pull from VSTS, build in Jenkins and deploy with VSTS.

  1. Create a Team Project
  2. Now import a Git repo
  3. Copy the Git repo URL

With our VSTS Team project created and source imported we can switch over to Jenkins.

  1. Add a new project to Jenkins to build your code
  2. For Source Code Management select Git
  3. Copy the Git repo URL in the Repository URL
  4. Click Add then Jenkins next to the Credentials drop down
  5. Enter the following
    Field Name Value
    Domain Global credentials (unrestricted)
    Kind Username with password
    Scope Global (Jenkins, nodes, items, all child items, etc)
    Username [Leave Blank]
    Password [VSTS Personal Access Token]
    Description VSTS
  6. Click Add
  7. Add a Archive the artifacts post-build action to archive output of build
  8. Save the project
    We will return to the project once we have the build firing so we can trigger the release

With the Jenkins project in place we can configure VSTS to start this build on every commit using a Service Hook.

  1. In VSTS add a new Service Hook
  2. Click Create subscription
  3. Select Jenkins
  4. Click Next
  5. Select Code pushed for Trigger on this type of event
  6. Click Next
  7. Enter the following
    Field Name Value
    Jenkins base URL [URL to Jenkins Server]
    User name [Your user name]
    User API token (or password) [Your password]
    Build [Build you want to trigger]
    Integration level TFS plugin for Jenkins
    The the rest blank
  8. Click Test
    The build in Jenkins should start
  9. Make sure the build succeeds
  10. In VSTS click Close
  11. Click Finish

With the build working we can create our release.

  1. Select Releases from the Build & Release menu
  2. Click New definition
  3. Select Empty
  4. Click Next
  5. Select Jenkins and click Manage
  6. Click New Service Endpoint and select Jenkins
  7. Enter the following
    Field Name Value
    Connection name Jenkins
    Sever URL URL to your Jenkins Server
    Accept untrusted SSL certificates [Depends on your Jenkins configuration]
    Username [Jenkins user name]
    Password [Jenkins password]
  8. Click Verify connection
  9. Click OK
  10. Return to the Create release definition dialog
    Click Build then Jenkins to force the new connection to show in dropdown
  11. Select Jenkins
  12. Select the project you want deploy
  13. Click Create
  14. Rename the release
  15. Click Save
    Configuring your release depends on the type of project you are building. The goal of this post is to wire up the parts so when you commit a change Jenkins is used to build the code and start a release in VSTS. So, I will leave the release empty.

With a release created we can now return to Jenkins to have it trigger this release when the build completes.

  1. Configure your Jenkins project
  2. Add a Trigger release in TFS/Team Services Post-build Action
  3. Enter the following
    Field Name Value
    Collection url https://[your VSTS]
    Team Project [Name of project you created]
    Release definition  
    Username [Leave Blank]
    Password or PAT [Personal Access Token]
  4. Click Save
  5. Click Build Now

Once the build is complete a release well be started.

Using the TFS Plugin for Jenkins makes it very easy to setup CI/CD between VSTS and Jenkins.

Comments (14) -

  • Great article.

    I am curious about how do I trigger next build using same artifacts that my current build used.
    In other words, I want to trigger my staging build using the same artifacts which my dev build used.

    I am able to trigger my staging build after dev build completes, but it (staging) uses the repository directly to get the latest changes. My problem here is if somebody merges the changes in-between these builds, there is a chance that staging might pick up the latest changes and not the changes with Dev was successful.

    Any help appreciated.
    • Why are you building the same code again? Should build once and simply deploy same binaries to each environment.
  • I don't know if it is only happening to me. But the trigger in Jenkins to VSTS obly works correctly when the Release Definition only have a Jenkins Artifact. If that definition has 2 or more artifacts (e.g. Git) it fails when triggering in Jenkins side.

    Except that, it is a great integration for autimation.
  • Hi,

    I am trying to set up with TFS 2015  via Jenkins with TFS plug in 5.2.
    I am getting an error :
    java.lang.NullPointerException on
    • Are you using a private or hosted agent?
  • Hi,

    TFS 2015

    Jenkins 1.655

    TFS Plug in 5.2.0

    I am setting up CI/CD with the TFS Plugin for Jenkins. I configured in my TFS 2015 the connection to my Jenkins Server , Connection was set up fine.

    But when I trigger in my job post build action using TFS plug in I am getting an Error:


    tfs.rm.ReleaseManagementCI.CreateRlease( java.lang.Null

    Any suggestion how to tackle such issue ?

    Thanks In Advanced for your help.
    • @Eldad
      Can you please share your logs with
  • How can I add Jenkins in the list option of New Service Endpoints ?
    • It should just be there. You don't have to install anything for it.
      • For some reason I just can see options Azure, Chef, Generic, Github and SubVersion

Pingbacks and trackbacks (1)+

Add comment