Lab 1 Report
Lab 1 Report
Link to a successful run of the CI/CD job that executed the game
https://gitlab.stud.atlantis.ugent.be/maximecoens/devops-project/-/jobs/248764
Structure of .gitlab-ci.yml
I implemented a pipeline with 3 stages in the .gitlab-ci.yml file.
- build (maven-build):
Compiles the project and downloads Maven dependencies. - package (maven-container-image-generation):
Builds Docker image and pushes it to the Gitlab registry. This is to prepare for execution. - execute (run-game):
Runs the game to test. It stops after 100 turns because of the set limit.
To make the pipeline faster and reuse certain files, cache and artifacts were implemented:
- Cache:
Stores Maven dependencies, so it don't need to be downloaded for every job. Allowing reuse of dependencies between jobs and pipelines. - Artifacts:
Stores compiled build files, they can be reused for other jobs within the same pipeline.
Problems encountered
- MAVEN_OPTS ignored by mvnw (+merge conflict)
Moved JVM options to ./mvn.jvm.config - Version 25 not supported
Downloaded Java 25 and changed version through:
sudo update-alternatives --config java
Questions:
What is ./mvnw and what is the advantage of using it above mvn?
./mvnw is the Maven Wrapper. It downloads and runs a specific Maven version for the project. The pros are that the same version of Maven is being used and there is no need to install Maven on the machine.
Explain the key differences between GitLab's cache and artifacts mechanisms. For each of Maven dependencies and build files, explain which mechanism you chose and why. What are the trade-offs of your choices?
- Cache: Stores Maven dependencies, so it can be reused for every job. Maven dependencies are easily reusable.
- Artifacts: Stores compiled build files, they can be reused for other jobs within the same pipeline.
I used cache for the Maven dependencies (they do not change often). They can be reused across popelines and jobs. I used artifacts for compiled builds of the project. These need to be shared within the same pipeline, which is perfect for artifacts. Caching makes the pipeline fast while artifacts make sure each pipeline run is consistent and reliable.
In this lab, we use a 25-jre image as the base for our runtime container and a 25-jdk image for the CI/CD build jobs. Explain the reasoning behind this choice. What would be the impact (positive or negative) of using 25-jdk for both? What about using 25-jre for both?
The 25-jdk image used for the CI/CD build jobs is chosen because it has everything needed to build and compile the project. The 25-jre image only contains what is needed to run the application (which makes it faster to download).
If you would use 25-jdk for both it would still work but the runtime image becomes large because it contains compnents that aren't needed after building, such as compilers.
If you would use 25-jre for both the runtime image would be very small this time but the build of the pipeline would fail. JRE does not have certain components that are needed for building such as compilers.