Visual Studio Team Services plugin

4 minute read

The Visual Studio Team Services plugin from CloudBees is deprecated. Microsoft recommends creating a service hook for Azure DevOps instead.

The Visual Studio Team Services plugin let you configure Jenkins to integrate with your Visual Studio Team Services account and setup CI jobs for your VSTS Git repositories. plugin do support branch and pull-request detection, as well as post-commit build triggers.

Development teams using Visual Studio Team Services can trigger Jenkins jobs based on source Git repository using a post-commit web hook. With a minimal setup on VSTS, they can setup a complete Continuous Delivery pipeline using such web hooks.

They also can rely on Jenkins to connect on your VSTS account and automatically detect branches and pull-requests (using multi-branch job types). With such a setup, team can rely on branches or pull-requests based development pipeline, and have Jenkins automatically setup to monitor the branches being used and publish build status.

Installing the Visual Studio Team Services plugin

  • Navigate to 'Manage Jenkins / plugin Manager' and ensure that the Visual Studio Team Services plugin is installed.

Figure 1. Jenkins - plugin Manager - Visual Studio Team Services plugin

Setting up Visual Studio Team Services Web Hook

The Visual Studio Team Services plugin do expose a generic web-hook receiver for Visual Studio Team Services to notify Jenkins on repository events. On VSTS repository administration view, 'Service Hooks' tab you can register hooks to integrate with external services. Visual Studio Team Services plugin do support generic "Web Hook" with following events:

  • Code pushed

  • Pull request created

  • Pull request updated

Service Hook can be created for all repositories in your account or for a specific repository and/or branch. Configuring a global hook for all repositories and branches make it simpler for you to configure your Visual Studio Team Services / Jenkins integration, as you won’t need additional setup on Visual Studio Team Services to configure new projects.

  • Go to your Visual Studio Team Services account dashboard.

  • Select 'Manage Account' (gear icon top right).

  • Select Default Collection to be configured.

  • Click 'View the project administration page'

  • Select 'Service Hooks' tab Please note Visual Studio Team Services do also offer a "Jenkins" Service Hook which can be used to trigger a specific Jenkins job with adequate authorization token. This Service Hook isn’t related to Visual Studio Team Services plugin.

Figure 2. Service Hook Setup
  • Click the Add (plus) button.

  • Select 'Web Hooks'

  • Select event trigger

  • Enter CloudBees Jenkins Enterprise URL and append /vsts-webhook/. You don’t need authentication for this specific web hook URL.

  • You can use the 'Test' button to check everything is well setup, then save.

Figure 3. Service Hook Setup

In your Jenkins job(s), you can now configure Build trigger "Build when a change is pushed to Visual Studio Team Services". With this option enabled, Jenkins will listen to Visual Studio Team Services events, and will compare enabled jobs SCM configuration to the notification source Git repository URL. If current job do match a Git commit notification, a polling cycle will run to check repository for changes and trigger a build if necessary.

Figure 4. Build Trigger Setup

Creating a Multi Branch job

The Visual Studio Team Services plugin is compatible with the Jenkins Branch API. Visual Studio Team Services git repositories appear as SCM sources in job types compatible with the Jenkins Branch API such as the Multibranch Pipeline plugin.

Using "Jenkinsfile" to define the build configuration with the source code

Multiple branches of a source code repository may require different build configurations. To solve this problem, the Multibranch Pipeline plugin uses a job definition stored with the source code in a file named Jenkinfile located at the root of the repository.

The Jenkinsfile uses the standard Jenkins Pipeline syntax. You just have to replace the source code checkout step (e.g. git '') with a special step checkout scm.

Sample 'Jenkinsfile' for a Maven project
node {
  stage 'Build and Test'
  env.PATH = "${tool 'Maven 3'}/bin:${env.PATH}"
  checkout scm
  sh 'mvn clean package'

The Jenkins Multibranch Pipeline plugin will index the git repository and create one build job per branch and per pull request containing a file Jenkinsfile.

Jobs created for pull requests are automatically deleted when the pull requests are closed.

Installing the Multibranch Pipeline plugin

Figure 5. Jenkins - plugin Manager - Multibranch Pipeline plugin

Creating a Jenkins Multibranch Pipeline job to build all the branches and pull requests

  • Create a Jenkins Pipeline Multi Branch project

Figure 6. Jenkins - New Pipeline Multi Branch Project
  • Navigate to the 'Branch Sources' section,

  • Select 'Visual Studio Team Services' in the 'Add Sources' dropdown list,

Figure 7. Jenkins - Multibranch Pipeline Project - Branch Sources
Figure 8. Jenkins - Multibranch Pipeline Project - Branch Sources - Visual Studio Team Services
  • Enter the name of the Visual Studio Team Services account (i.e.,

  • Enter the desired Visual Studio Team Services credentials.

    • Generate a Visual Studio Team Services Personal Access Token on the Visual Studio Team Services profile page ("Security" tab) granting at least the code read scope.

    • Create Jenkins credentials of type 'username/password credentials', the username will not be used, you can use your account name for triage

Figure 9. Visual Studio Team Services - Profile Page - Personal Access Token
  • Once valid credentials are entered, the 'Repository' drop down list is populated with the list of available Git repositories

  • Select the desired repository

Once the project is saved, Jenkins indexes the Git repository and creates one sub-project per branch and per pull-request. Such a setup lets you get a dedicated build history per branch, or per pull-request, and adopt a branch based git development pipeline.

Figure 10. Jenkins - Multibranch Pipeline Project - Sub Jobs
In August 2020, the Jenkins project voted to replace the term master with controller. We have taken a pragmatic approach to cleaning these up, ensuring the least amount of downstream impact as possible. CloudBees is committed to ensuring a culture and environment of inclusiveness and acceptance - this includes ensuring the changes are not just cosmetic ones, but pervasive. As this change happens, please note that the term master has been replaced through the latest versions of the CloudBees documentation with controller (as in managed controller, client controller, team controller) except when still used in the UI or in code.