Master Jenkins CI for SpringBoot: From Build to Remote Deployment

This guide walks you through configuring Jenkins to build a SpringBoot Maven project, automating post‑build steps, managing the workspace, and securely transferring the resulting JAR to another server using SSH keys or an Expect script.

Java Backend Technology
Java Backend Technology
Java Backend Technology
Master Jenkins CI for SpringBoot: From Build to Remote Deployment

This article explains how to set up Jenkins for a SpringBoot Maven project, covering job creation, source code configuration, build commands, and post‑build actions.

The project resides at https://gitee.com/xuliugen/ufind-server. After ensuring Jenkins is installed, create a new job (ignore the "already exists" warning) and configure the following:

Project name and description.

Git repository URL and credentials.

Build step: mvn clean package -Dmaven.test.skip=true (skips tests).

Post‑build step: custom shell script to copy the generated JAR, set export BUILD_ID=dontKillMe, kill any previous process, and start the new JAR in the background while recording its PID in ufind-web.pid.

The Jenkins workspace is located at

/home/xuliugen/.jenkins/workspace/ufind-server/ufind-web/target

, where the compiled JAR appears.

To move the JAR to another server, use scp. Because scp prompts for a password, two methods are presented:

Establish password‑less SSH trust : generate an RSA key pair with ssh-keygen -t rsa, copy the public key to the remote host's ~/.ssh/authorized_keys (or use ssh-copy-id), and repeat for bidirectional trust.

Use an Expect script : install expect and write a script that automates the password prompt. Key commands are send, expect, spawn, and interact. Example snippets are shown in the original images.

After setting up the trust or Expect automation, the JAR can be transferred and started on the remote host (e.g., 192.168.1.241) via a remote startup.sh script.

All configuration steps are now complete, and the SpringBoot service can be accessed through a browser.

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/cdDeploymentmavenSpringBootJenkinsShell scripting
Java Backend Technology
Written by

Java Backend Technology

Focus on Java-related technologies: SSM, Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading. Occasionally cover DevOps tools like Jenkins, Nexus, Docker, and ELK. Also share technical insights from time to time, committed to Java full-stack development!

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.