This guide provides a walkthrough of .razorops.yaml for a typical Java based application based. Our CI process is going to consist of following steps -
- Install dependencies (
mvn install) - Build executable (
mvn package) - Running tests (
mvn test)
We recommend you use docker based workflow for easier operations and immutable deployment. If not, you can directly jump below to use non-docker based tasks.
Docker based
I assume you are familiar with Docker concepts, if not please refer here to know more about the advantages of Docker.
Build/Test steps
If you have Dockerfile in the root of your source repository, you can build a container image and use that container image to run your test suit. For example -
tasks:
build-image:
type: build
name: registry.example.com/java/app
tags: ["${CI_COMMIT_SHA}", "latest"]
build-executable:
image: registry.example.com/java/app:latest
commands:
- mvn -Dtest=<class> test
Non-Docker based
Installing dependencies
Using official maven docker image:
tasks:
build-deps:
image: maven:3.6.0-jdk-11-slim
commands:
- mvn -q clean package -Dmaven.test.skip=true
Read more how to use this image on dockerhub docs.
TIP
You can further speedup the workflow by caching maven dependencies so that every subsequent build then performs just incremental changes on top of that during npm install which may lead to even faster builds.
Execute test suite
Using official maven docker image:
tasks:
build-deps:
image: maven:3.6.0-jdk-11-slim
commands:
- mvn -Dtest=<class> test
You can additionally provide environment variables and provide service dependencies to run your test suite.