Operations 7 min read

One‑Click Jenkins + Docker + Spring Boot Deployment: Step‑by‑Step Guide

This tutorial walks you through setting up a complete CI/CD pipeline on CentOS 7 using Docker, Jenkins, and Spring Boot, covering Docker installation, Jenkins container deployment, plugin and Maven configuration, job creation, Dockerfile setup, and automated project build and run.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
One‑Click Jenkins + Docker + Spring Boot Deployment: Step‑by‑Step Guide

This article demonstrates a complete one‑click Jenkins + Docker + Spring Boot deployment pipeline on CentOS 7, covering environment setup, Docker installation, Jenkins container deployment, plugin configuration, Maven setup, job creation, build triggers, Dockerfile creation, and running the application.

Environment

CentOS 7 + git (gitee).

Install Docker

Update yum packages

yum update

Remove old Docker versions

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

Install required packages

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

Add Docker repository

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

Install Docker CE

yum install docker-ce  # installs the latest stable version (e.g., 17.12.0)
# or install a specific version, e.g.:
# yum install docker-ce-17.12.0.ce

Start Docker and enable on boot

systemctl start docker
systemctl enable docker

Verify installation

docker version

Install Jenkins

Run Jenkins in a Docker container (ensure port 8080 is free):

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 follow the initialization steps on the official site.

Unlock Jenkins

Enter the container: docker exec -it jenkins bash Retrieve the initial admin password:

cat /var/lib/jenkins/secrets/initialAdminPassword

Install Plugins

Choose “Install suggested plugins” and then create an admin user.

System Configuration

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

Configure Maven

Navigate to Manage Jenkins → Global Tool Configuration → Maven and set up Maven installation.

Create Job

New Job

Create a “Freestyle project” with a suitable name.

Source Code Management

Select Git, enter the repository URL, and add credentials.

Build Triggers

Configure desired triggers (e.g., poll SCM, webhook).

Build Steps

Add a “Invoke top‑level Maven targets” step with goals such as:

clean install -Dmaven.test.skip=true

Save

Save the job configuration.

Test Build

Click “Build Now” and monitor the console output. The first run may download dependencies; a second run should succeed.

Check Workspace

cd /var/jenkins_home/workspace
ls

Run Project

Since Jenkins and the project share the same server, use a shell script to build a Docker image and run the container.

Dockerfile

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

Jenkins Job Adjustments

After the Maven build, add shell commands to stop, remove, and rebuild the Docker container:

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

Note: Avoid using docker logs -f in the build step, and use || true to prevent failures when the image does not yet exist.

Verify

docker ps          # confirm container is running
docker logs zx-order   # view application logs

Open http://{SERVER_IP}:8888 in a browser to test the deployed Spring Boot service.

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/cdautomationSpring BootJenkins
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

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.