Development environment¶
To start the lab assignments you will need the following tools installed on your system:
- Git
- JDK 21 (Java Development Kit)
- IntelliJ IDEA Community or Ultimate edition
- Docker (see Docker tutorial for installation instructions)
In the following we provide some instruction on how to install these tools. If you already have them installed, you can proceed to the next section: Prepare and test your DevOps project.
Package Manager¶
The Lab sessions depend on a number of tools that need to be installed on your system. Manual installation of these tools can be cumbersome (installing dependencies, configuring the path, etc...) and error-prone. That is why we will rely on package managers to perform the installation.
For Windows users, we recommend using Scoop. To install Scoop, execute the following commands in a Powershell terminal:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression
This requires PowerShell 5.1 (or later) and .NET Framework 4.5 (or later) to work!
For macOS users, we recommend using Homebrew. To install Homebrew, execute the following command in a terminal:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Linux users can use Homebrew as well, or rely on the built-in package manager of the specific installation (e.g. apt-get on Debian and Ubuntu).
For Linux users, we recommend using the built-in package manager of your distribution (e.g. apt-get on Debian and Ubuntu).
Alternatively you could also rely on tools such as snap
or flatpak
to install software packages, or even homebrew if you prefer.
Install Git¶
Git has become the industry standard for version control and is the most commonly used. It is a distributed version control system, meaning your local copy of code is a complete version control repository. These fully-functional local repositories make it easy to work offline or remotely. You commit your work locally, and then sync your copy of the repository with the copy on the server. This paradigm differs from centralized version control (such as CVS or SVN) where clients must synchronize code with a server before creating new versions of code.
If you don't have Git installed, you can install it using a package manager:
scoop install git
brew install git
sudo apt-get install git-all
sudo dnf install git-all
You can use Git via its CLI interface or via a third-party UI application (e.g. Sourcetree). IDEs such as IntelliJ IDEA and VS Code also have built-in git tools.
Tip
If you have no previous experience with Git, a guide with a basic overview can be found here. Git commands will be used heavily throughout the Lab sessions, so it is important to get familiar with the basics.
Do not use Git Bash on Windows
If you have Git already installed and have access to Git Bash terminal. Do not use this terminal to do any of the Lab assignments. It is only suited to run git commands.
Install JDK¶
A JDK allows you to compile and execute Java-based applications. Install the latest JDK using a package manager:
scoop bucket add java
scoop install temurin21-jdk
brew tap homebrew/cask-versions
brew install --cask temurin@21
We refer to official installation instructions for Linux on the Adoptium website.
This page however instructs you to install JDK 17, so be sure to change the command appropriately to install JDK 21.
You have to add correct sources after which you can install the JDK using your package manager.
Install IDE¶
An Integrated Development Environment (IDE) is an application that supports a developer in writing applications, e.g. by providing code-completion, a debugging framework, project navigation, etc.
Which IDE to use, is up to you, as the project is built using Maven (which should work across IDEs) and straight from commandline. However, we recommend using IntelliJ IDEA since it is the most-used Java IDE and has excellent support for Maven.
VS Code is also a good alternative, especially if you are already familiar with it. Though it's IntelliSense/Code Analysis engine for Java is not as powerful as IDEA's.
IDEA has a Community and an Ultimate version: https://www.jetbrains.com/idea/download/other.html The Community version is free and should suffice for this project. However, the Ultimate version can be used at no cost by University students: https://www.jetbrains.com/community/education/#students/.
Prepare and test your DevOps project¶
First you will need to create a User account on our GitLab server. Go to the following page https://gitlab.stud.atlantis.ugent.be/ and click on the Register button.
Please use your UGent email address and username to register. This way we can easily find you in the system and give you the right permissions.
Visit our repository at https://gitlab.stud.atlantis.ugent.be/devops-public/devops-project and click the fork button in the top right corner of the screen. GitLab will prompt you to "Select a namespace to fork the project". Select your name to create the forked project in your own user-space.
You should now see this project in the Projects overview, accessible from the left sidebar.
GitLab¶
A large variety of DevOps or CI/CD related technologies and tools exist. Popular applications include Jenkins and CircleCI. Free git repository host sites such as GitHub and Bitbucket are also offering more and more integration options to help you build a complete DevOps solution.
For this course, we chose to use GitLab as the platform for teaching you the practical aspects of DevOps.
- GitLab is presented as a Web application with a user-friendly interface.
- GitLab has a powerful and extensible system for running CI/CD Jobs based on a declarative pipeline configuration.
- GitLab features integrated Issue trackers and Wiki pages to help you organize your project.
- GitLab has a per-project Docker Image registry, which you will leverage for automated deployments later.
The GitLab instance you will be using is hosted at IDLab (our research group) with the goal of providing you with a responsive experience without usage limitations (public services such as GitHub and Bitbucket will throttle git operations in order to ensure fair usage across their userbase).
Also take the time, to set up a profile picture (recognizable, preferably the same as your UGent account) on GitLab through https://gitlab.stud.atlantis.ugent.be/-/profile after registering.
Clone Git repository¶
To start working on the project, you are going to need a local version of the repository on your computer. Visit your forked repository on GitLab. You should see a Clone button on the landing page:
Clone directly with IntelliJ or copy the Clone with HTTPS URL and execute the following command in the folder where you want to store the project:
git clone <Copied URL>
You will be prompted to enter your username and password. Check the output log to see if the command was successful!
Note
If git requires you to select a credential helper, you can select store. This simple helper will store the credentials you use for remote repositories on disk, preventing you from having to enter your username and password for git commands interacting with the remote repository.
Windows users: beware when entering your credentials!
In some configurations, git will automatically store your credentials using the Windows Credentials application. When this is the case, wrong credentials will be reused (login will not prompt again) and you can only clear this using the Windows Credentials application.
Build the project¶
After cloning the repository, navigate to the project directory:
cd devops-project
Now you can test your JDK installation by running the following command:
./mvnw clean install
You should see maven start downloading dependencies and building the project, resulting in a successful build. If you see any errors, please check the installation of your JDK.
[INFO] Installing /home/jveessen/devops/devops-project/target/logic-service-1.0.0-SNAPSHOT.jar to /home/jveessen/.m2/repository/be/ugent/devops/project/logic-service/1.0.0-SNAPSHOT/logic-service-1.0.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 18.187 s
[INFO] Finished at: 2024-10-01T13:51:40+02:00
[INFO] ------------------------------------------------------------------------