https://docs.microsoft.com/en-us/azure/devops/pipelines/release/caching?view=azure-devops
https://docs.microsoft.com/en-us/azure/devops/pipelines/release/caching?view=azure-devops#maven
Maven
Maven has a local repository where it stores downloads and built artifacts. To enable, set the maven.repo.local
option to a path under $(Pipeline.Workspace)
and cache this folder.
Example:
YAML
variables:
MAVEN_CACHE_FOLDER: $(Pipeline.Workspace)/.m2/repository
MAVEN_OPTS: '-Dmaven.repo.local=$(MAVEN_CACHE_FOLDER)'
steps:
- task: Cache@2
inputs:
key: 'maven | "$(Agent.OS)" | **/pom.xml'
restoreKeys: |
maven | "$(Agent.OS)"
maven
path: $(MAVEN_CACHE_FOLDER)
displayName: Cache Maven local repo
- script: mvn install -B -e
If you are using a Maven task, make sure to also pass the MAVEN_OPTS
variable because it gets overwritten otherwise:
No comments:
Post a Comment