构建缓存与加速策略
CI/CD 缓存加速 Maven 构建。
GitHub Actions 缓存
YAML
- uses: actions/cache@v3
with:
path: ~/.m2/repository
key: maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
maven-
GitLab CI 缓存
YAML
cache:
paths:
- .m2/repository/
variables:
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
Jenkins 缓存
groovy
options {
durabilityHint('PERFORMANCE_OPTIMIZED')
}
steps {
sh 'mvn clean install -o' // 离线模式使用缓存
}
要点总结
- actions/cache GitHub Actions 缓存
- cache paths GitLab CI 缓存
- -o 离线模式使用缓存
- MAVEN_OPTS 配置本地仓库路径
📝 发现内容有误?点击此处直接编辑