Operations 8 min read

One‑Click Jenkins + Docker + SpringBoot Deployment: Step‑by‑Step Guide

This tutorial walks you through a complete one‑click Jenkins, Docker, and SpringBoot automated deployment on CentOS, covering environment preparation, Docker and Jenkins installation, plugin configuration, job creation, build testing, and running the packaged application in a Docker container.

macrozheng
macrozheng
macrozheng
One‑Click Jenkins + Docker + SpringBoot Deployment: Step‑by‑Step Guide

This article demonstrates a comprehensive one‑click Jenkins + Docker + SpringBoot automated deployment, detailing environment setup, Docker installation, Jenkins installation, system configuration, job creation, build testing, and running the project.

Install Docker

Update yum packages: yum update Remove old Docker versions (if any):

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 (latest stable): yum install docker-ce Start Docker and enable on boot:

systemctl start docker
systemctl enable docker

Verify installation:

docker version

Install Jenkins

Pull and run the Jenkins Blue Ocean image:

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://{SERVER_IP}:8080 and wait for initialization.

Unlock Jenkins:

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

Install the recommended plugins and create an admin user.

System Configuration

Install required plugins: Maven Integration, Publish Over SSH (optional), Gitee (if using Gitee), etc.

Configure Maven in Manage Jenkins → Global Tool Configuration and set up Maven installation.

Create Jenkins Job

New Item → Freestyle project.

Source Code Management → Git: provide repository URL and credentials.

Build Steps → Invoke top‑level Maven target: clean install -Dmaven.test.skip=true Save the job.

Test Build

Click Build Now and monitor the console output to ensure the JAR is produced.

If the first build fails to download dependencies, trigger another build.

Run the Project

Create a Dockerfile in the SpringBoot project root (no file extension):

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"]

Update the Jenkins job to add shell steps that rebuild 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 the job and trigger a build. Verify the container is running with:

docker ps
docker logs zx-order

Access the application in a browser at http://{SERVER_IP}:8888 to confirm successful deployment.

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/cdautomationSpringBootJenkinsCentOS
macrozheng
Written by

macrozheng

Dedicated to Java tech sharing and dissecting top open-source projects. Topics include Spring Boot, Spring Cloud, Docker, Kubernetes and more. Author’s GitHub project “mall” has 50K+ stars.

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.