Azure-devops-docs: Deployment Job doesn't automatically check out sources

Created on 18 Sep 2019  Â·  9Comments  Â·  Source: MicrosoftDocs/azure-devops-docs

I think (and correct me if I'm wrong) that a deployment job doesn't automatically clone the source repo. This is different to the behaviour of regular jobs.

It would be useful to mention that on this page.


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Pri1 devops-cictech devopprod doc-enhancement

Most helpful comment

I agree, this should be made clear in the docs.

All 9 comments

This confused me just now. The deployment job knew which template reference to use, but then couldn't find any source file.

What are the recommended tasks/steps to make sure the source repo is downloaded successfully in the same location as if it were a regular job?

@LarsCelie you can use this in your pipeline yaml

steps:
- checkout: self  # self represents the repo where the initial Pipelines YAML file was found
  clean: boolean  # if true, execute `execute git clean -ffdx && git reset --hard HEAD` before fetching
  fetchDepth: number  # the depth of commits to ask Git to fetch; defaults to no limit
  lfs: boolean  # whether to download Git-LFS files; defaults to false
  submodules: true | recursive  # set to 'true' for a single level of submodules or 'recursive' to get submodules of submodules; defaults to not checking out submodules
  path: string  # path to check out source code, relative to the agent's build directory (e.g. \_work\1); defaults to a directory called `s`
  persistCredentials: boolean  # if 'true', leave the OAuth token in the Git config after the initial fetch; defaults to false

https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema#checkout

This works, thanks for advice!

strategy:
  runOnce:
    deploy:
      steps:
      - checkout: self
      - task: KubernetesManifest@0

I am finding that the deployment job (as of this post) downloads artifacts from earlier build job but it downloads them to D:a1 as opposed to D:a1a ( the System.ArtifactsDirectory )
This makes using the files difficult.

@henry-padilla it downloads to the Pipeline.Workspace directory. You can work around that by defining a custom download artifact task.

steps:
- download: none
- task: DownloadBuildArtifacts@0
  inputs:
     artifactName: $(artifactName)
     buildType: 'current'
     downloadType: 'single'
     downloadPath: '$(System.ArtifactsDirectory)'

Wouldn't that cause the download to happen twice? It's better knowing where the files are, I can simply use them from there.

Thank you very much for the information. It's very helpful.

- download: none disables the automatic download task. But yeah, simply using Pipeline.Workspace is probably the cleanest solution.

These advices are exactly what I expected to find on the page but found only in the comments.

I agree, this should be made clear in the docs.

Was this page helpful?
0 / 5 - 0 ratings