Home > Back-end >  yaml checkout only triggering branch
yaml checkout only triggering branch

Time:09-28

I want to avoid fetching every single branch everytime i do a checkout in my pipeline. I have a template which looks like this. Is there anyway for me to specify so that i only checkout out the branch that triggered the run

jobs:
  - job: zzz
    displayName: "yyy"
    pool:
      vmImage: 'xxx'
    steps:
      - checkout: self
        lfs: false
        fetchDepth: 0
      - task aaa
      .
      .
      .

This is how my template looks at the moment, and what is want is something like this (not valid syntax)

jobs:
  - job: zzz
    displayName: "yyy"
    pool:
      vmImage: 'xxx'
    steps:
      - checkout: self@$(Build.SourceBranch)
        lfs: false
        fetchDepth: 0
      - task aaa
      .
      .
      .

Is there any way to achive this?

CodePudding user response:

You can use the following format:Checking out a specific ref to checkout the repo with the variable.

- checkout: git://MyProject/MyRepo@features/tools 

For example:

steps:
- checkout: git://projectname/Reponame@$(Build.SourceBranch)
  fetchDepth: 0

Then it will checkout the branch based on the pipeline variable:Build.SourceBranch

  • Related