Azure DevOps YAML build pipeline : Where is checkout?
Tags: azure, devops, yaml
Published: 2020-01-20 07:32:04

---
title: Azure DevOps YAML build pipeline : Where is checkout?
published: true
description: 
tags: azure,devops,yaml
cover_image: https://thepracticaldev.s3.amazonaws.com/i/p3vmmj2cga30lo7lu5xd.jpg
---

I use Azure DevOps for long time, and I always use GUI when crafting Build Pipeline so far, though I knew Azure DevOps supports YAML and its benefits.

So this time, I tried YAML instead of GUI and I learnt many things. In this article, I talk about **"checkout"** task. 

When I first created YAML pipeline, my first question was where is my source code checkout information inside YAML as I only saw **trigger**. I eventually figured out but I leave memo here.

# GUI experience

The very first thing I see in GUI is "select a source", which includes:
- Type of repository
- Where is the repo
- Which branch to checkout
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/ittuxz59bquskmsgqjtz.jpg)

After that, I select template. This time, I select "empty job" as I build dotnet core console app.
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/m6emtpef5pwxxky3v5ox.jpg)

Then adding bunch of tasks as I needed.
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/fxir4gizgfmb0jg7fdmn.jpg)

I see **"Get sources"** at the beginning which is the starting point.

# YAML experience

Now let's see the YAML experience. I start by selecting repository type.
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/0q8kt76ajv1fff8stb2s.jpg)

Then select actual repository.
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/yjwrl468wzi5o5aeq8ne.jpg)

Then select template.
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/jage6bok5yw5fa5g7ktu.jpg)

And this is the generated YAML.

```yaml
# .NET Desktop
# Build and run tests for .NET Desktop or Windows classic desktop solutions.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/apps/windows/dot-net

trigger:
- master

pool:
  vmImage: 'windows-latest'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@1

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: VSTest@2
  inputs:
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'
```

So there are several things I didn't understand at the begining.

- Where is **"Get sources"** or **checkout task**?
- How to set branch as source?
- Where did the repository information go?

Also that the YAML file is saved in either master or new branch. As I usually block direct commit to master branch, I created new branch.
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/421xlh8a0gnpajc93mup.jpg)

# Checkout mystery

First of all, I need to figure out the **checkout** stuff. By reading [Check out multiple repositories in your pipeline](https://docs.microsoft.com/en-us/azure/devops/pipelines/repos/multi-repo-checkout?view=azure-devops#specify-multiple-repositories), I understand it's omitted by default.

>The following combinations of checkout steps are supported.
If there are no checkout steps, the default behavior is as if checkout: self were the first step.

When I run the pipeline as it is, I see **checkout** task as expected.
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/a3dswbgyhynyfy2v1sko.jpg)

The **"self"** is the branch it's triggered the pipeline. If I trigger it manually, I can select which branch to run it, then the **self** becomes the branch I selected.

# Set branch

So I don't have to set which branch to checkout, but simply configure the trigger. [Specify events that trigger pipeline builds and releases](https://docs.microsoft.com/en-us/azure/devops/pipelines/build/triggers?view=azure-devops&tabs=yaml) provides enough information to me.

# The repository Info

There is a settings I can change to specify the repository. Click [...] for more menu and click "Trigger". (Not settings)
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/4e9al6wp78kd2y0gk7e6.jpg)

There are several settings I can change. Go to YAML tab and I can change the repository.
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/ted1h3pnqiqr72eq1gif.jpg)

# Summary

In this article, I only talk about "checkout" task, and I just need to know the concept and basics, then it's not that different from GUI version anyway.

There are many other things I learnt which I will make note later.