26

I have a pipeline with multiple stages, and the source code is checked out automatically on all of them. I do not need the source code, but only published artifacts.

How can disable source code checkout for specific stages?

jhurtas
  • 555
  • 1
  • 6
  • 17

1 Answers1

50

Use Checkout option: https://learn.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema%2Cparameter-schema#checkout

Example:

trigger:
- main

pool:
  vmImage: 'ubuntu-latest'

jobs:
- job: no_checkout
  steps:
  - checkout: none

  - script: echo Hello, world!
    displayName: 'Run a one-line script'

- job: checkout
  steps:
  - script: echo Hello, world!
    displayName: 'Run a one-line script'
Shamrai Aleksander
  • 13,096
  • 3
  • 24
  • 31
  • 1
    Perfect, thanks! I found the documentation for the "checkout" step here: https://learn.microsoft.com/en-us/azure/devops/pipelines/yaml-schema/steps-checkout?view=azure-pipelines – Ken Lyon May 06 '22 at 16:26
  • 1
    Is there a way to skip the items *Checkout* and *Post-job: Checkout* in the list presenting the stages, jobs and steps? Currently, I have *Initialize job*, *Checkout*, *Post-job: Checkout* and *Finalize Job* for every job. I'd like to see it only for the jobs that actually deal with the source code. – Konrad Viltersten Jun 11 '23 at 13:08