Build a repo with YAML file

[ad_1]


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.

Prerequisites

  • 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
.NET Core https://github.com/adventworks/dotnetcore-sample
Android https://github.com/adventworks/android-sample
Go https://github.com/adventworks/go-sample
Java https://github.com/adventworks/java-sample
JavaScript https://github.com/adventworks/nodejs-sample
PHP https://github.com/adventworks/php-sample
Python https://github.com/adventworks/python-sample

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:

  1. On the Code hub for your team project in VSTS, select the option to Import repository.

  2. In the Import a Git repository dialog box, paste the above URL into the Clone URL text box.

  3. Click Import to copy the sample code into your Git repo.

Get your first build

  1. In VSTS, navigate to the Code hub, choose the Files tab, and then choose the repository you created in the above steps.

  2. Inspect the .vsts-ci.yml file 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.

  3. Go back to the list of files and select the Readme.md file, and then choose Edit.

  4. Add the following comment:

    # This repository is built using VSTS.
    
  5. Commit the above change to the master branch.

  6. Navigate to the Build and Release hub.

  7. 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.

  8. 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

  1. Once the build completes, select the build number to view a summary of the build.

    Navigate to build summary

  2. 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.

Next steps

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.

[ad_2]

source_link
https://www.asp.net