1. Install Java 11
Jenkins requires Java (but does not declare it as a dependency).
sudo apt-get install openjdk-11-jdk-headless
2. Install Jenkins
Follow the Debian/Ubuntu Jenkins installation steps.
Add Jenkins Key
curl -fsSL https://pkg.jenkins.io/debian/jenkins.io.key | sudo tee \
/usr/share/keyrings/jenkins-keyring.asc > /dev/null
Add Jenkins Repository
echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
https://pkg.jenkins.io/debian binary/ | sudo tee \
/etc/apt/sources.list.d/jenkins.list > /dev/null
Update and Install Jenkins
sudo apt-get update
sudo apt-get install jenkins
Check Jenkins Status
systemctl status jenkins
3. Install Maven
sudo apt install maven
4. Access Jenkins
Jenkins runs on port 8080.
Open in browser:
http://13.233.91.31:8080/
5. Initial Setup
- Get the initial password:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
- Login using this password.
- Install required plugins (especially Maven Plugin).
6. Install Maven Plugin (if not installed)
Go to:
Manage Jenkins → Manage Plugins → Available Plugins
Search and install:
- ✅ Maven Integration Plugin
7. Configure Maven Path
Go to:
Manage Jenkins → Global Tool Configuration
Under Maven:
- Uncheck ✅ Install automatically
- Set Maven Home Path (example):
/usr/share/maven
Click Save.
8. Configure Global Security
Go to:
Manage Jenkins → Configure Global Security
Under CSRF Protection:
- ✅ Check Enable Proxy Compatibility
Click Save.
9. Create Jenkins Job
Click:
New Item → Maven Project
10. Configure Git Repository
In Source Code Management:
- Select Git
- Enter your repository URL
11. Configure Build Trigger
Enable polling every 5 minutes:
H/5 * * * *
12. Configure Build (pom.xml)
In Build section:
- Enter path of
pom.xml
Example:
myexample/pom.xml
13. Post Build Steps (Continuous Deployment)
Add shell script to:
- Copy generated JAR file
- Run Spring Boot app
Example logic:
- Copy from:
/var/lib/jenkins/workspace/dataprocessingproject/myexample/target
- To:
/home/ubuntu
- Run:
java -jar myapp.jar
14. Allow Jenkins to Run Commands Without Password
Edit sudoers file:
sudo visudo
Add this line at the end:
jenkins ALL=(ALL) NOPASSWD: ALL
Save:
- Press
Ctrl + O - Press
Ctrl + X
15. Build the Job
Click Build Now.
Jenkins will:
- Connect to GitHub
- Pull source code
- Run Maven build
- Generate JAR file:
/var/lib/jenkins/workspace/dataprocessingproject/myexample/target/myapp.jar
- Copy JAR to:
/home/ubuntu
- Run Spring Boot application
16. Access Spring Boot Application
From browser:
http://<server-ip>:<spring-boot-port>
Top comments (0)