Operations 7 min read

Automate Multi‑Service Deployment with Jenkins in a Microservice Architecture

This guide shows how to use Jenkins to automate the packaging and deployment of a multi‑module microservice project, covering script preparation, job creation for each service, startup order recommendations, and one‑click deployment for rapid releases.

macrozheng
macrozheng
macrozheng
Automate Multi‑Service Deployment with Jenkins in a Microservice Architecture
In a microservice architecture, deploying many services becomes cumbersome; this article demonstrates how to use Jenkins to achieve one‑click automated deployment for the eight‑service mall-swarm project.

Basic Jenkins Usage

Refer to the Jenkins tutorial for one‑click packaging and deployment of SpringBoot applications.

Prepare Deployment Scripts

First, prepare the scripts that will be executed remotely.

All script files are stored in the mall-swarm project's /document/sh directory.

Before uploading, change the line‑ending format of all script files to LF in the IDE, otherwise the scripts may fail to run.

Upload all scripts to the target directory, e.g., /mydata/sh.

Make the scripts executable:

chmod +x ./mall-*

Create Jenkins Jobs

We create Jenkins jobs to automate deployment. Because mall-swarm is a multi‑module project, the process differs from single‑module projects.

mall-admin

Select Build a freestyle software project, name the job mall-admin, and configure the Git repository (e.g., a Gitee URL).

Add a build step to install the dependent modules of mall-swarm so that subsequent module builds succeed:

# Install only mall-common, mall-mbg, mall-security modules
clean install -pl mall-common,mall-mbg,mall-security -am

Add another build step to build and package the mall-admin module alone.

Add a build step that uses SSH to execute the remote deployment script for mall-admin.

Save the job.

mall-registry

The creation process is similar to mall-admin ; only the pom.xml location and script path need to be adjusted.

Copy the mall-admin job and rename it.

Modify the second build step’s pom.xml path to ${WORKSPACE}/mall-registry/pom.xml.

Modify the third build step’s SSH script path to /mydata/sh/mall-registry.sh.

Save the job.

Other Modules

For the remaining modules, follow the same pattern as mall-admin and mall-registry.

Module Startup Order

The mall-registry module must start first, followed by mall-config ; other modules have no strict order.

Recommended startup sequence:

mall-registry

mall-config

mall-monitor

mall-gateway

mall-admin

mall-portal

mall-search

mall-demo

Conclusion

By creating Jenkins jobs, we have automated the packaging and deployment of services in a microservice architecture, enabling one‑click deployment after code changes and eliminating repetitive manual steps.

Project Repository

https://github.com/macrozheng/mall-swarm

Recommended Reading

Key points of “flash sale” system design.

Using Jenkins for one‑click SpringBoot packaging and deployment.

Technical challenges of number portability across carriers.

Differences between novice and senior programmers.

Integrating SpringSecurity + JWT for authentication.

Essential Nginx tricks you might not know.

Spring Cloud tutorial covering core components.

My open‑source project’s journey to 20k stars.

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/cdautomationDeploymentJenkins
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.