Current setting in my testing job is to run a "mvn clean verify" script to execute an integration test for my application.
But the problem is the mvn clean verify will rebuild and re-download dependencies everytime it run so it will be really time consuming.
I'm currently using shared runner and can't have dedicate runner for my test. Is there anyway for me to cache the maven downloaded dependencies and plugins?
currently I'm thinking about build a docker that store m2 folder and put it in the pipeline like this
test:
stage: test
image: my.registry/maven.dependencies
script:
- mvn verify -Dtags=@TEST -Denv=default
I figured out the answer through Gitlab's sample CI CD pipeline.
For maven what you need to do is add these following environment variables configs
MAVEN_OPTS: "-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true"
using these OPTS to specify the dependencies saved folder
And then adding those line for cache
cache:
key: new_cache
paths:
- .m2/repository/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.