GitLab CI pipelines
You can start by having a quick to the official introduction to pipelines and jobs documentation.
We are going to see how to make a pipeline as follows:
graph LR;
subgraph build
B(mvn compile);
end
subgraph test
C(mvn test);
end
B-->C
Artifacts
In order to use compilation build results in the test job, compilation results have to be saved as an artifact.
Let's modify the .gitlab-ci.yml
file as follows :
stages:
- build
- test
job_build:
stage: build
tags:
- linux
script:
- cd java
- mvn compile
artifacts:
expire_in: 2 hrs
paths:
- java/target/
- the
test
stage is added -
mvn compile
compiles undertarget
directory. -
java/target
folder is saved as an artifact
java/target/
folder is present in the
.gitignore
file.
Exercise
Add a job_unit_test
as a test
stage that runs the unitary tests of the
project.
job_build
.
Commit and push the .gitlab-ci.yml
file and check the job_unit_test
is
Tips and tricks
You can use GitLab CI linter
to validate your .gitlab-ci.yml
file before pushing it.
Home | Java Home | << Java Previous - Jenkins setup | >> Java Next - Pre-computation