In this project we are creating Jenkins CI CD of git
> github
> jenkins
> maven
to build
war file > deploy to tomcat 8 server
with deploy to container
plugin.
Prerequisites
- EC2 instance with tomcat 8 installed
- Jenkins with Maven Server
- Deploy to container plugin installed
- Setup Tomcat Credentials
Installation of Deploy to container
plugin
Manage Jenkins
>Jenkins Plugins
>available
>deploy to container
Setup credentials of Tomcat
To deploy our build artifacts on tomcat server our Jenkins server need access. For that we should setup credentials. This option is available in Jenkins Dashboard
.
Manage Jenkins
>Manage Credentials
> UnderStores scoped to Jenkins
on the right, click onJenkins
> UnderSystem
, click theGlobal credentials (unrestricted)
link to access this default domain > ClickAdd Credentials
on the left. >- From the
Kind field
chooseUsername and password
- Username :
deploy
- Password :
XXXXXXX
- id :
Tomcat_user
- Description:
Tomcat user to deploy on tomcat server
- From the
Steps to create Jenkin job
- Login to Jenkins console
- Create Jenkins job, Fill the following details,
- Enter Item name:
Simple Devops Project 1
Maven Project
- Source Code Management:
- Repository:
https://github.com/maheshkn400/hello-world.git
- Branches to build : */master`
- Repository:
- Build:
- Root POM:
pom.xml
- Goals and options :
clean install package
- Root POM:
- Post Steps
- Deploy war/ear to container
- WAR/EAR files :
**/*.war
- Containers :
Tomcat 8.x
- Credentials:
Tomcat_user
# (which created in above step) - Tomcat URL :
http://<PRIVATE_IP>:<PORT_NO>
- Credentials:
- WAR/EAR files :
- Deploy war/ear to container
- Enter Item name:
Save and run the job now.
Continuous Integration & Continuous Deployment (CI/CD)
Now job is running fine but to make this as Continuous Integration and Continuous Deployment To do that go back and modify job as below.
- Build Triggers
- Poll SCM
- schedule */2 * * * *
- Poll SCM
Save the job and modify the code in GitHub. Then you could see your job get trigger a build without any manual intervention.
I'm Happy To Get Suggestions 😄