How to use this cache for python requirements caching ? Will this cache task works if we use Hosted Agent for build
Asked
Active
Viewed 948 times
0
-
Hi Did you check out below solution. How did it go? – Levi Lu-MSFT Sep 18 '20 at 03:35
1 Answers
1
In documentation you have examples how to use cahce with requirements.txt
file.
variables:
PIP_CACHE_DIR: $(Pipeline.Workspace)/.pip
steps:
- task: Cache@2
inputs:
key: 'python | "$(Agent.OS)" | requirements.txt'
restoreKeys: |
python | "$(Agent.OS)"
python
path: $(PIP_CACHE_DIR)
displayName: Cache pip packages
- script: pip install -r requirements.txt
And Pipefile.lock
:
variables:
PIPENV_CACHE_DIR: $(Pipeline.Workspace)/.pipenv
steps:
- task: Cache@2
inputs:
key: 'python | "$(Agent.OS)" | Pipfile.lock'
restoreKeys: |
python | "$(Agent.OS)"
python
path: $(PIPENV_CACHE_DIR)
displayName: Cache pipenv packages
- script: pipenv install
Taks should run without any issue on Self Hosted Agents if you have all prerequisites installed:
What is worth to mention this doesn't work with Azure DevOps Server.

Krzysztof Madej
- 32,704
- 10
- 78
- 107