Deploying Springboot app to PROD using Jenkins Pipeline projects
Firstly we have to set up a Jenkins
Creating a Job
click on new item
enter job name
choose pipeline
click on OK
Our job is created.

Now we will install the required dependencies in our Master server
Required installations:
Java 17
maven
git
yum install java-17-amazon-corretto.x86_64
using the above command java gets installed.
Maven setup:
first, we have to download maven
wget https://dlcdn.apache.org/maven/maven-3/3.9.1/binaries/apache-maven-3.9.1-bin.tar.gz
unzip and move maven to /opt -->
tar xvf apache-maven-3.9.1-bin.tar.gz -C /opt
to link with maven 3.9.1 -->
sudo ln -s /opt/apache-maven-3.9.1/ /opt/maven
To setup maven with java 17 we have to create write a script file 'maven.sh'
sudo vim /etc/profile.d/maven.sh
export JAVA_HOME=/usr/lib/jvm/java-17-amazon-corretto export M2_HOME=/opt/maven export MAVEN_HOME=/opt/maven export PATH=${M2_HOME}/bin:${PATH}
we have to give executable permissions to the file and execute the script
sudo chmod +x /etc/profile.d/maven.sh
source /etc/profile.d/maven.sh
Now you can verify the maven version using
mvn -v
Apache Maven 3.9.1 (2e178502fcdbffc201671fb2537d0cb4b4cc58f8)
Maven home: /opt/maven
Java version: 17.0.6, vendor: Amazon.com Inc., runtime: /usr/lib/jvm/java-17-amazon-corretto.x86_64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.10.173-154.642.amzn2.x86_64", arch: "amd64", family: "unix"
Installing git
yum install git
Till now we have done set up in local/jenkins server
Now we are going to set up the required dependencies in the PROD server
Required dependencies:
Java 17
tomcat 10
visit this link to set up tomcat
visit this link to SSH-KEY generation
github url:

below is the pipeline script
pipeline {
agent any
stages {
stage('code') {
steps {
git branch: 'main', url: 'https://github.com/vishalsiripuram/newSpringWar.git'
}
}
stage('build') {
steps {
sh '/opt/maven/bin/mvn clean package'
}
}
stage('deploy') {
steps {
sh 'scp -o strictHostKeyChecking=no target/*.war root@172.31.92.53:/opt/apache-tomcat-10.1.7/webapps'
}
}
}
}