Reputation: 13680
I have azure debug pipeline that looks like below. I use $(Build.SourcesDirectory)
azure variable to list content of my repository. Unfortunately, for some reason the content of SourcesDirectory
is empty. Why? What am I doing wrong? I remember that it used to work.
pool:
vmImage: ubuntu-latest
stages:
- stage: Debug
displayName: Debug
jobs:
- deployment: Debug
displayName: Debug
strategy:
runOnce:
deploy:
steps:
- task: CmdLine@2
displayName: Debug
inputs:
script: |
echo 'Build.SourcesDirectory'
echo $(Build.SourcesDirectory)
ls -l $(Build.SourcesDirectory)
Upvotes: 3
Views: 5267
Reputation: 13680
I still don't know the reason behind why it didn't work in first place (I guess some pipeline permissions or settings that I don't have/know) but, I found the fix that worked for me.
I had to add checkout: self
step (docs) before my debug task.
pool:
vmImage: ubuntu-latest
stages:
- stage: Debug
displayName: Debug
jobs:
- deployment: Debug
displayName: Debug
strategy:
runOnce:
deploy:
steps:
# The Fix!
- checkout: self
- task: CmdLine@2
displayName: Debug
inputs:
script: |
echo 'Build.SourcesDirectory'
echo $(Build.SourcesDirectory)
ls -l $(Build.SourcesDirectory)
Upvotes: 5