DEV Community

Cover image for Azure DevOps YAML build pipeline : Where is checkout?
Kenichiro Nakamura
Kenichiro Nakamura

Posted on


Azure DevOps YAML build pipeline : Where is checkout?

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

After that, I select template. This time, I select "empty job" as I build dotnet core console app.
Alt Text

Then adding bunch of tasks as I needed.
Alt Text

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

Then select actual repository.
Alt Text

Then select template.
Alt Text

And this is the generated 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:

- master

  vmImage: 'windows-latest'

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

- task: NuGetToolInstaller@1

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

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

- task: VSTest@2
    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

Checkout mystery

First of all, I need to figure out the checkout stuff. By reading Check out multiple repositories in your pipeline, 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

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

There are several settings I can change. Go to YAML tab and I can change the repository.
Alt Text


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.

Top comments (2)

useric profile image
Iurie Caradja • Edited

Its probably not relevant at this point but since there are no answers, here is the documentation reference for this topic:

by default there is no need to do anything as it is handled by the pipeline, but if you want, you can specify your custom configuration for the git operations

edit: grammar

kenakamu profile image
Kenichiro Nakamura

Thanks for the info! Yeah, we don't need to specify it but I was a bit curious how "automagically" checkout happens :)