azure-devopsazure-pipelines-yaml

Checkout before stages in YAML


Im doing a checkout in my stages to download the repo.

stages:
- stage: dev    
  jobs:
  - deployment: DeploySQLObjects
    displayName: "Deploy SQL objects" 
    environment: "Synapse_DEV"
    strategy:   
      runOnce:
        deploy:
          steps:   
          - checkout: self 

- stage: test
  .......

- stage: prod
  .......

Is it possible do to the checkout before all stages and let all stages use this checkout?

I'm not quite sure how to do it. I've only seen examples with steps without stages.


Solution

  • If you are using Azure Hosted build agents, each job will use a new build instance. In this case, you can not use one checkout step...

    If you are using Self Hosted build agents, you may add one checkout stage to some shareable folder through git commands and use it for other jobs.