How to refer to a file in Azure Devops
Azure Devops is a necessary evil. I mean someone or something has to run my code, and I prefer it not being me.
Last week, I ran into the case where I had to pull up a config from a file and load it into my pipeline. I asked ChatGPT and this is what I was told to do.
To reference a specific file in Azure Devops, use the Build.SourcesDirectory
variable that is available for each build.
Say we want to refer to the file models/active_models.json
which is input for src/run.py
like this:
$ tree
models
├── active_models.json
src
├── run.py
Then we can simply do this:
- task: AWSShellScript@1
inputs:
scriptType: 'inline'
inlineScript: |
python ./src/run.py --path $(Build.SourcesDirectory)/models/active_models.json
Comments