Jenkins with Visual Studio Online

On my current project we’re using Jenkins as a CI platform and Visual Studio Online with TFS for source control. I’ve been wanting to setup the builds on our intranet again to run the integration tests relying on intranet access each check-in. I had an issue with this, as I did last time I tried it and figured I need to retain this information somewhere.

If you are doing this with using Git you’ve come to the wrong place though, Microsoft has a great article about that themselves.

This is the error I ended up getting:

FATAL: The SOAP endpoint could not be contacted. HTTP status: 404
java.lang.RuntimeException: The SOAP endpoint could not be contacted. HTTP status: 404

The issue was finding the right URL to use, which is the base URL for your VSO project including DefaultCollection. I.e. You can find this if you look really, really closely at the change history of the plug in.

  1. Have a Jenkins server
  2. Install the Visual Studio Plugin
    1. Click Manage Jenkins then Manage plugins
    2. Switch to Available tab
    3. Filter for Team Foundation Server Plug-in and install
  3. Create a personal access token for VSO
    1. Log into VSO
    2. In the upper right corner, click on your name, My profile and then the Security tab
    3. Add and follow instructions, make sure you copy the password because once that’s lost its lost. That’s the idea behind a token. When it expires you’ll create a new one the same way.
  4. Setup a new build project (probably freestyle unless you’ve got other needs)
  5. Under source code management select Team foundation server this will give you some new options
    VSO Jenkins config
  6. As mentioned above, you want to use your email and the token you created for authentication. As for the server URL, that should be your VSO DefaultCollection url and the source path you can find by selecting a folder under Code in VSO and getting the path that begins with $.
  7. As for when to trigger the build I choose to do it every fifteen minutes using a Poll SCM trigger with the following value

    Jenkins Poll SCM
  8. Then the build step of course
    Jenkins MSBuild step

The node running this job has msbuild (visual studio) installed of course and I also had to manually append the msbuild bin folder to the system %PATH% variable in order for Jenkins to execute it. Since the path variable is defined when launching the jenkins client I had to restart that to get it working as well.

In the end all is well and that’s ”all” you have to do to get it working.. It does save a lot of time in the long run though.