Lab 1 Report
Include a link to a successful run of the CI/CD job that executed the game.
https://gitlab.stud.atlantis.ugent.be/jasdridd/devops-project/-/jobs/248721
Report on the structure of your .gitlab-ci.yml, detailing problems you encountered and how you solved them.
The file is build up in multiple parts, first it declares some global settings like variables, stages that are in the pipeline and a cache. After that it defines the job for each stage. First it will build up the maven package by gathering all the dependencies and compiling it. In the second phase it take the compiled code and turn it into something that can be executed. The final stage will execute the game.
Encountered problem: The cache didn't get found in between jobs.
Solution: I added a line to my CI script in the first stage, - mkdir -p .m2/repository, to make sure the folder exists. After I added that line, I had no warnings anymore about the cache not being found and it could load the cache.
What is ./mvnw and what is the advantage of using it above mvn?
mvnw refers to a Maven wrapper script that comes with the project. It downloads a project-compatible version of Maven that will only be used within the context of the project you use it in. This makes it easier for developers to collaborate and prevents you from having to install Maven on your system. It also prevents compatibility issues when you are working on different maven projects with different versions.
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 can be shared across pipelines and jobs, but is not stored and not downloadable when the job is done.
- Artifacts are stored on the GitLab server and are available in the pipeline. They are stored for a configurable amount of time (by using "expires in:" in the yaml-file). It can also be downloaded from the pipeline view.
I used a cache between my jobs to have everything shared across a common space between my stages. This avoids the need to redownload the same dependencies again if a later stage requires it. The bad side of this trade off is that it can become very large and have an impact on runtime and resource usage.
I used an artifact to transfer the output of my building stage as input to my packaging stage. It is used to make sure that the next stage gets exactly what it needs from the previous stage. The negative trade off with artifacts is that there is overhead with downloading/uploading the artifacts.
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?
- A JRE image contains only the Java Runtime Environment needed to run compiled Java applications. JDK images contain the full Java Development Kit, including the compiler, debugging tools and the runtime environment.
- The reasoning to use a jdk for the CI/CD build jobs is that you need the compiler to build the java application. But you don't need the compiler to run the image of the already compiled application. That is why a runtime container will make use of a jre-image instead of a jdk-image.
- The impact of using 25-jdk for both would be that the runtime container would be downloading unnecessary stuff, because the program is already compiled, it doesn't need it. It would need more resources than necessary.
- The impact of using only 25-jre however, would give problems. The code is not compiled, and cannot be ran without a compiler. So the CI/CD build jobs would fail because of it, making the pipeline fail in total.