Before beginning to this article make sure Jenkins Server is already setup and running. This article covers how to use Jenkins for Build Automation and Deployment over Tomcat Server for Spring application.
Step 1: Configure Global Variables:
1.1 JAVA : Manage Jenkins → Global Tool Configuration → JDK Installations → Add JDK
1.2 Git : Manage Jenkins → Global Tool Configuration → Git
Step 2: Configure Deployment Plugin:
2.1 Manage Jenkins → Plugin Manager → Available → Search “Deploy to container Plugin” → Install
Step 3: Configure Tomcat Credentials:
3.1 Credentials → System → Global Credentials → Add Credentials → Enter Tomcat manager credentials
Step 4: Project Setup and Configurations:
2.1 Jenkins → New Item → Freestyle project
2.2 General
For saving the project repository in different workspace select “use custom workspace” as follows:
2.3 Source Code Management
Add repository URL, select credentials and specify the source branch to pull.
2.4 Build Triggers
2.5 Build: Execute using shell script
2.6 Post-build Actions
2.6.1 Archive .war files
2.6.2 Deploy wat to Tomcat Container
Step 4: Build Progress:
Make sure Build is successfully created