I am new to gitlab CI and trying to build my maven project using gitlab.
I created my own docker image for builds and I am using my local runner.
My .gitlab-ci.yml
looks as below: Edited:
image: registry.gitlab.com/girishenoy2003/docker-java-8-mvn-3.6.3:latest
services:
- docker:dind
stages:
- compile
- test
before_script:
- export MVN_USER_HOME=`pwd`/.m2
cache:
paths:
- $MVN_USER_HOME/.m2/repository/
- target/
maven-compile:
stage: compile
script:
- mvn compile
tags:
- my-local-runner
only:
- master
maven-test:
stage: test
script:
- mvn test
tags:
- my-local-runner
only:
- master
During the compile stage I expect all the dependencies to download and cache it and while running test I expect it to get it from cache as I am using my local runner for both jobs.
How can we avoid download of dependent jars from downloading in different jobs?
P.S.:
- I already looked at this question - but didn't help
- I know that if I use
mvn test-compile
it will do the trick but I wanted to make it in different jobs to segregate the stages
Edit: Some runner logs:
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in /builds/aws-learning-path/spring-boot-rest/.git/
Checking out f86f9c63 as master...
Removing "..\\..\\..\\cache\\aws-learning-path\\spring-boot-rest\\default\\cache.zip"
Removing target/
Skipping Git submodules setup
Restoring cache
00:00
Checking cache for default...
No URL provided, cache will not be downloaded from shared cache server. Instead a local version of cache will be extracted.
Successfully extracted cache
Executing "step_script" stage of the job script
$ export MVN_USER_HOME=/root
$ mvn test
[INFO] Scanning for projects...
Downloading from central: https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-parent/2.2.2.RELEASE/spring-boot-starter-parent-2.2.2.RELEASE.pom
Downloaded from central: https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-parent/2.2.2.RELEASE/spring-boot-starter-parent-2.2.2.RELEASE.pom (8.1 kB at 3.3 kB/s)