Setting up CI/CD with the TFS Plugin for Jenkins 19 March 2017 Donovan Work (19) 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 Fully installed and configured Jenkins server Team Foundation Server Plugin Free Visual Studio Team Services (VSTS) account Personal Access Token With the above we are ready to configure a project to pull from VSTS, build in Jenkins and deploy with VSTS. Create a Team Project Now import a Git repo Copy the Git repo URL With our VSTS Team project created and source imported we can switch over to Jenkins. Add a new project to Jenkins to build your code For Source Code Management select Git Copy the Git repo URL in the Repository URL Click Add then Jenkins next to the Credentials drop down 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] ID VSTS Description VSTS Click Add Add a Archive the artifacts post-build action to archive output of build 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. In VSTS add a new Service Hook Click Create subscription Select Jenkins Click Next Select Code pushed for Trigger on this type of event Click Next 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 Click Test The build in Jenkins should start Make sure the build succeeds In VSTS click Close Click Finish With the build working we can create our release. Select Releases from the Build & Release menu Click New definition Select Empty Click Next Select Jenkins and click Manage Click New Service Endpoint and select Jenkins 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] Click Verify connection Click OK Return to the Create release definition dialog Click Build then Jenkins to force the new connection to show in dropdown Select Jenkins Select the project you want deploy Click Create Rename the release 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. Configure your Jenkins project Add a Trigger release in TFS/Team Services Post-build Action Enter the following Field Name Value Collection url https://[your VSTS].visualstudio.com Team Project [Name of project you created] Release definition Username [Leave Blank] Password or PAT [Personal Access Token] Click Save 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.