Operations 8 min read

One‑Click Jenkins & Docker CI/CD for Spring Boot Projects

This guide walks you through installing Docker and Jenkins on CentOS 7, configuring Jenkins plugins, creating a freestyle job that builds a Spring Boot application with Maven, and deploying it via a Dockerfile for fully automated one‑click deployment.

Java High-Performance Architecture
Java High-Performance Architecture
Java High-Performance Architecture
One‑Click Jenkins & Docker CI/CD for Spring Boot Projects

This article demonstrates how to set up a one‑click automated deployment pipeline for a Spring Boot project using Docker and Jenkins on a CentOS 7 host.

Install Docker

Update yum packages: yum update Remove old Docker versions:

yum remove docker docker-common docker-selinux docker-engine

Install required utilities:

yum install -y yum-utils device-mapper-persistent-data lvm2

Add Docker CE repository:

yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

Install Docker CE: yum install docker-ce Start Docker and enable on boot:

systemctl start docker
systemctl enable docker

Verify installation:

docker version

Install Jenkins

Run Jenkins container:

docker run --name jenkins -u root --rm -d -p 8080:8080 -p 50000:50000 -v /var/jenkins_home:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock jenkinsci/blueocean

Access Jenkins at http://{host_ip}:8080 and complete the initial setup.

Unlock Jenkins by retrieving the admin password from the container:

docker exec -it jenkins bash
cat /var/lib/jenkins/secrets/initialAdminPassword

Install recommended plugins, including Maven Integration, Publish Over SSH, and Gitee (if needed).

Create an admin user.

System Configuration

Install required plugins: Maven Integration, Publish Over SSH, Gitee, etc.

Configure Maven under “Global Tool Configuration”.

Create a Jenkins Job

Create a new “Freestyle project”.

Configure source code management with Git, providing repository URL and credentials.

Add a build step “Invoke top‑level Maven targets” with goal clean install -Dmaven.test.skip=true.

Save the job.

Test Build

Trigger a build and monitor the console output to ensure the JAR is produced.

If dependencies fail to download on the first attempt, rebuild.

Locate the workspace at /var/jenkins_home/workspace and verify the JAR.

Run the Project

Create a Dockerfile in the Spring Boot project root:

FROM jdk:8
VOLUME /tmp
ADD target/zx-order-0.0.1-SNAPSHOT.jar app.jar
EXPOSE 8888
ENTRYPOINT ["bash","-DBash.security.egd=file:/dev/./urandom","-jar","/app.jar","--spring.profiles.active=prd"]

Add a build step in the Jenkins job to build and run the Docker image:

cd /var/jenkins_home/workspace/zx-order-api
docker stop zx-order || true
docker rm zx-order || true
docker rmi zx-order || true
docker build -t zx-order .
docker run -d -p 8888:8888 --name zx-order zx-order:latest

Save and build the job.

Verify the container is running with docker ps and view logs with docker logs.

Access the application in a browser at http://{host_ip}:8888.

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.

Dockerci/cdautomationDevOpsSpring BootJenkins
Java High-Performance Architecture
Written by

Java High-Performance Architecture

Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.

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.