Operations 7 min read

Master Jenkins CI: Step-by-Step Setup, Plugins, and Automated Deployment

This guide walks through setting up a Jenkins CI server—including environment preparation, installation, essential plugins, system and project configuration, security hardening, and a custom shell script for automated deployment—providing a practical roadmap for reliable continuous integration and delivery in Java projects.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Master Jenkins CI: Step-by-Step Setup, Plugins, and Automated Deployment

Introduction

Continuous integration has become mainstream, enabling frequent testing and early issue detection; automated deployment speeds up releases and reduces human error.

1. Development Environment

The development environment includes:

Maven for project management.

Git for source control.

SpringMVC + Spring + MyBatis framework.

MySQL with Druid connection pool.

Unitils testing framework.

Hibernate Validator for data validation.

Log4j for logging.

2. Jenkins Installation

Jenkins (formerly Hudson) can be downloaded from http://jenkins-ci.org/. Install by placing the WAR file into Tomcat and starting Tomcat. Configuration files reside in ~/.jenkins. It is recommended to run Jenkins on Linux to avoid missing commands like ssh.

3. Jenkins Plugins

After installation, access http://IP:port/jenkins, go to “Manage Jenkins → Manage Plugins”. Initially the plugin list may be empty; wait a minute.

3.1 Git Plugin

Install “Git plugin” from “Available Plugins” and enable the restart‑after‑install option.

3.2 Email Plugin

Update “Mailer Plugin” and optionally install “Email Extension Plugin” for richer email content.

3.3 Other Plugins

Common plugins such as Maven and JUnit are installed by default; upgrade if needed.

4. System Settings

Navigate to “Manage Jenkins → Configure System”. Important items:

Set paths for Java, Git, Maven.

Verify the automatically generated Jenkins URL.

Configure email settings, including the system administrator address and extended e‑mail notification.

5. Project Configuration

Create a new job and configure:

1. Source Code Management: select Git, provide Repository URL and credentials (private key can be pasted directly).

2. Build Triggers: enable “Build periodically” and “Poll SCM” with the same schedule, e.g., “H/15 * * * *”.

3. Build Steps: add “Execute shell” and “Invoke top‑level Maven target” in the desired order.

Example shell script (customize as needed) can modify database connection settings; the Maven step runs “mvn clean test”.

4. Publish JUnit test result report: add “*/target/surefire-reports/*.xml”.

5. Email Notification: add “Editable Email Notification”, specify recipients, use global variables, and set trigger conditions.

6. Security Configuration

After a successful build, enable security under “Configure Global Security”:

Enable security.

Use Jenkins’ own user database and allow user registration.

Set authorization strategy to “Matrix‑based security”, create an “admin” user with all permissions.

Set admin password.

After testing the admin login, disable anonymous access and remove its permissions.

7. Automated Deployment

Deployment is triggered manually via a custom script to avoid excessive redeployments during frequent testing. Example script:

#!/bin/sh

# update code
git pull

# package
mvn clean
mvn package -Dmaven.test.skip=true

# deploy
WAR=`ls target | grep war`
TOMCAT=/home/test/apache-tomcat-6.0.41
mv target/$WAR $TOMCAT
cd $TOMCAT
# invoke another deploy script
sh deploy-war.sh $WAR webapps
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/cdDevOpsGitmavenJenkinsshell script
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.