Maven project for devops
Create AWS Account I hope you have created one already. if you don't have please create another one
Click on ec2 services it will show the ec2 dashboard.
Click on Launch Instances.
create t2 micro instance with free tier. I am using here t2 micro instances with low configuration but it will not give smooth experience.
select ubuntu machine
create key pair and name this file then save
Add security group If you dont have create another one
After Creating an instance connect via ssh
Steps for installing Jenkins
- Before Installtion jenkins Make sure you have java installed in your system
# switch to root user to install packages
$ sudo su
$ apt update
$ apt install openjdk-11-jdk -y
# after installtion of java check version
$ java --version
After Installation of java, you can install Jenkins.
Follow the command or you can also use documentation if you want to install Jenkins for another operating system.
Installation of Jenkins https://www.jenkins.io/doc/book/installing/
# add the framework repository key
$ curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo tee \
/usr/share/keyrings/jenkins-keyring.asc > /dev/null
# Link the repository of Debian Package to the source list of the server
$ echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
https://pkg.jenkins.io/debian-stable binary/ | sudo tee \
/etc/apt/sources.list.d/jenkins.list > /dev/null
# update packages list
$ apt update
# insallation jenkins
$ apt install jenkins
- To check that installation of Jenkins is complete and running run command "service Jenkins status"
Jenkins services are running
After the successful installation of Jenkins visit with your server domain name or IP address : your_server_ip:8080
You have to allow Incoming traffic for your instance.
steps for allow incoming traffic go_to_ec2_dashboard > Running instances > Security > security_groups > Edit Inbound Rules
Edit Inbound Rules. type ->all tcp , source -> anywhere ipv4 . I am allowing all tcp because I have to forward other port also.
Save Rules then try to again open it .
unlock jenkins password is saved on this location
cat
/var/lib/jenkins/secrets/initialAdminPassword
you will get the passwordpaste password then continues installing suggested plugins.
Make fresh User save and finish you will see the dashboard of jenkins
Installation of Maven Application
Click on manage plugins > plugin manager > available plugins
Install the Maven Integration plugin then click install without restart this plugin helps to create maven project .
Same as installing deploy to container plugin
After Installing plugins create credentials for the tomcat user.
If you don't have tomcat server running on the server. create it first.
you can also check my blog on how to run tomcat server
Go to Dashboard > Manage Jenkins > Credential > System > Global Credential
Go to the dashboard Click on New Item create new Project
Click on Ok.
Add github repository Link
Tick on Poll Scm. polls the SCM periodically for checking if any changes/ new commits were made and shall build the project if any new commits were pushed since the last build.
Schedule it for 2 minutes according to their formula.
Maven installation by jenkins click on tool configuration
Build > Goal and Option >clean install package
After the maven command, all commands are executed.
Add Maven from Maven installation Save and Apply.
Deploy war/ear to the container.
Click on Build Now. Now, wait for the build production it will deploy your application on the tomcat server.
visit on your_ip:8090/webapp tomcat server. the application will be deployed