Operations 5 min read

Deploying a Spring Application with Jenkins, GitLab, Docker Compose, and Maven

This guide walks through deploying a Spring application using Docker Compose, Jenkins, GitLab, and Maven, covering password retrieval, plugin installation, GitLab host configuration, access token creation, Jenkins setup, Maven build commands, and verification of the generated JAR file.

Practical DevOps Architecture
Practical DevOps Architecture
Practical DevOps Architecture
Deploying a Spring Application with Jenkins, GitLab, Docker Compose, and Maven
[root@hd03 ~]# docker-compose -f /root/docker-compose.yml up -d

To view the Jenkins admin password, navigate to the secrets directory and display the initialAdminPassword file: [root@hd03 secrets]# pwd /data/jenkins/secrets [root@hd03 secrets]# cat initialAdminPassword 337699819bc745ae80d155654dcc59b7

System Configuration

During installation, select the following plugins under System Management → Plugin Management → Optional Plugins → Deploy to container:

1. Deploy to container

2. Maven Integration

3. Publish Over SSH

4. SSH (including SSH server plugin to push the built JAR to a remote server)

5. Install ansible

Modify the GitLab host entry from [email protected] to the actual IP address: [root@hd03 etc]# pwd /data/gitlab-rails/etc

Update the host configuration accordingly.

1. Generate a GitLab Access Token

In GitLab, go to Settings → Access Tokens and create a new token.

Configure the GitLab connection in Jenkins using the generated token.

1) Deploy the Spring Project

1. Upload the project to GitLab

2. Build a Maven project

3. Configure Git

4. Set up a build trigger (pom.xml)

In pom.xml use the command: clean package -e -U -Dmaven.test.skip=true 5. Execute the build

The test did not publish successfully.

Inspect the build output directory: [root@hd03 target]# pwd /data/jenkins/workspace/xiang/target [root@hd03 target]# ll drwxr-xr-x 3 root root 47 Feb 10 11:42 classes

-rw-r--r-- 1 root root 16102407 Feb 10 11:42 demo-0.0.1-SNAPSHOT.jar

-rw-r--r-- 1 root root 2937 Feb 10 11:42 demo-0.0.1-SNAPSHOT.jar.original

... (additional file listings) ...

At this point, the Spring project has been successfully deployed.

For earlier articles on Jenkins + GitLab deployment, please refer to the previous posts.

If this article helped you, please like, view, and share—it greatly supports my continued creation of quality content. Thank you 🙏🏻

Like, view, and share, and scan the QR code to follow; more detailed articles will be organized later.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

ci/cdDeploymentspringGitLabJenkins
Practical DevOps Architecture
Written by

Practical DevOps Architecture

Hands‑on DevOps operations using Docker, K8s, Jenkins, and Ansible—empowering ops professionals to grow together through sharing, discussion, knowledge consolidation, and continuous improvement.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.