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.
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
I see "Get sources" at the beginning which is the starting point.
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: # 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?
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.
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.
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.
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.