If you manage your code in GitHub or in Visual Studio Team Services (VSTS) Git, then you can use VSTS pipelines to easily build the repo by adding a YAML file to it. VSTS pipelines can be used to automate continuous integration (CI) for an application written in any programming language.
- A VSTS account. If you don’t have one, you can create one for free. If your team already has one, then make sure you are an administrator of the team project you want to use.
Get the sample code
Choose the sample application for the language of your choice from one of the following repositories.
|Programming language||Repository with sample application|
Get the code for the sample application into your own GitHub or VSTS repository.
To import the sample app into a Git repo in VSTS:
On the Code hub for your team project in VSTS, select the option to Import repository.
In the Import a Git repository dialog box, paste the above URL into the Clone URL text box.
Click Import to copy the sample code into your Git repo.
Get your first build
In VSTS, navigate to the Code hub, choose the Files tab, and then choose the repository you created in the above steps.
.vsts-ci.ymlfile at the root of your imported repository. The YAML file contains the instructions for the build process. Here’s an example snippet from a Gradle build definition. The actual content in your file depends on the sample application you chose.
queue: 'Hosted VS2017' steps: - task: Gradle@2 inputs: gradleWrapperFile: 'gradlew' testResultsFiles: '**/TEST-*.xml' tasks: 'build'
The next time you change any file in this repository, VSTS automatically builds your code.
Go back to the list of files and select the Readme.md file, and then choose Edit.
Add the following comment:
# This repository is built using VSTS.
Commit the above change to the master branch.
Navigate to the Build and Release hub.
Observe that there’s a new build pipeline named name-of-your-repo YAML CI. A build is queued; its status could be either not started or running. Choose the number of the build: yearmonthday.1.
After an agent is assigned to your job and the agent is initialized, then you’ll see information about the build in the console.
View the build summary
Once the build completes, select the build number to view a summary of the build.
Notice the various sections in the build summary – the source version of the commit in build details section, list of all associated changes, links to work items associated with commits, and test results.
When the build is automatically triggered by a push to your Git repository, these sections are populated with all the relevant information.
You’ve just learned the basics of using YAML to create and run a VSTS build process.
This pipeline automatically builds and validates whatever code is checked in by your team.
Now you’re ready to configure your CI definition for the programming language you’re using.