4. Tooling Images
GitLab Runner can use Docker to run jobs on user provided images. This is possible with the use of Docker executor.
The image keyword is the name of the Docker image the Docker executor uses to run CI/CD jobs. You can specify different images for different jobs. For example, choose an Image which contains a Java Development Kit (JDK) for building Java Applications or an Image which contains the .NET SDK for building C# apps.
In this Lab section we will show you how to choose and use the right Container Image.
GitLab References
Task 4.1: Choosing tooling images
To build an application or to deploy it, specific languages, frameworks or tools are needed.
Therefore, we need to find the right Container Image.
Good sources for Container Images are trusted registries like Red Hat . You can also use official Images from the software company developing the needed tool.
For tools and languages it is a good starting point to check the Pre-Built CircleCI Docker Images .
Info
Using freely available Container Images is risky. Be aware of the security constraints.Task 4.2: Build the application
The example source is a Java 17 application. For that we use the openjdk-17 Image from Red Hat.
Create a new job inside .gitlab-ci.yml with the following configuration:
- job name:
build_application - stage:
build - image:
registry.access.redhat.com/ubi9/openjdk-17:latest - script:
./gradlew assemble
Don’t forget to add the build stage to the stages list.
Task 4.3: Check the pipeline
The pipeline should now look like this:
stages:
- info
- build
info:
stage: info
script:
- echo "This is your first stage (ツ)"
build_application:
stage: build
tags:
- build
- mobiliar
image: registry.access.redhat.com/ubi9/openjdk-17:latest
script:
- ./gradlew assemble
After committing the changes a new pipeline starts using the updated configuration.
Go to your GitLab project and check the pipelines under Build –> Pipelines.
The Java application is built using the Gradle Build Tool
Check the Gradle build log and verify whether the build succeeded or not.
Starting a Gradle Daemon (subsequent builds will be faster)
> Task :compileJava
> Task :processResources
> Task :classes
> Task :resolveMainClassName
> Task :bootJar
> Task :jar
> Task :assemble
BUILD SUCCESSFUL in 39s
5 actionable tasks: 5 executed
Cleaning up file based variables
00:00
Job succeeded