0

I'm trying to implement Approval gates in an Azure Devops YML pipeline and following these steps. An issue I am seeing is that since configuring the pipeline to use a blank environment (so it is only used for the approval process as per the article) when the pipeline runs I am no longer seeing the "Checkout" step where my repo contents are loaded into the virtual machine runner used by the pipeline. How can I use an environment and load in the repo contents?

This code has the checkout step:

trigger: none

pool:
  vmImage: ubuntu-latest

stages:
  - stage: tempname
    jobs:
      - job: tempname
        steps:
        - bash: |
            echo hello world

This code does not have the checkout step:

trigger: none

pool:
  vmImage: ubuntu-latest

stages:
  - stage: tempname
    jobs:
      - deployment: tempname
        environment: test
        strategy:
          runOnce:
            deploy:
              steps:
                - bash: |
                    echo hello world
avres
  • 7
  • 3
  • I'm not 100% clear on what you are asking, but perhaps https://stackoverflow.com/questions/66114165/disable-source-code-checkout-in-specific-pipeline-stages is relevant? By default there is always a `checkout: self` step which loads the code from the repo but you can add `checkout: none` if you don't want to check out the code. Also, perhaps you might consider agentless jobs (see https://docs.microsoft.com/en-us/azure/devops/pipelines/process/phases?view=azure-devops&tabs=yaml#types-of-jobs). If you add a minimal example of your pipeline, it might be easier to understand your issue? – Andrew McClement Mar 04 '22 at 19:03
  • Thank you for your assistance. I have edited my answer to include the YML which has the checkout step and the YML which does not. I am trying to figure out if/where I can add a checkout step as I have not set that before. – avres Mar 04 '22 at 20:25

1 Answers1

1

checkout is a step, so should go in the steps section - see https://learn.microsoft.com/en-us/azure/devops/pipelines/yaml-schema/steps-checkout?view=azure-pipelines.

Example of how it might look:

trigger: none

pool:
  vmImage: ubuntu-latest

stages:
- stage: tempname
  jobs:
  - deployment: tempname
    environment: test
    strategy:
      runOnce:
        deploy:
          steps:
          - checkout: self # Use none to avoid checking out code.                  
          - bash: |
              echo hello world
Andrew McClement
  • 1,171
  • 5
  • 14