Jenkins Live Project

Jenkins Live Project

Let's first understand what Jenkins, GitHub, Webhook, S3, and Maven are:

Jenkins is an open-source automation tool written in Java with plugins built for Continuous Integration and Continuous deployment/delivery purposes.

GitHub is a code hosting platform for collaboration and version control. It lets you and others work together on projects.

Webhook is a mechanism to automatically trigger the build of a Jenkins project in response to a commit pushed to a Git repository.

Maven is a powerful project management tool that is based on POM (project object model). It is used for project build, dependency, and documentation.

JUnit is an open-source Unit Testing Framework for JAVA. It is useful for Java Developers to write and run repeatable tests.

1. Install Jenkins in your system.
2. Add appropriate plugins to connect with other tools.
3. Set up the Webhook link in GitHub for your account.

Jenkins Installation:-

Jenkins is a Java-based framework.
Before installing Jenkins you have to install Java in your system.

As per the above picture, Java is not installed in your system.
Let's try to install Java First.
Before installing Java update your system first with the help of the below command.
"sudo apt update"

Once the system is updated successfully try to install Java using the below command.
"sudo apt install openjdk-11-jre"

Now check if Java is successfully installed or not using the below command.
"java --version"

Now use the below command to install Jenkins setup.

"curl -fsSL pkg.jenkins.io/debian-stable/jenkins.io-202.. | sudo tee \ /usr/share/keyrings/jenkins-keyring.asc > /dev/null echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \ pkg.jenkins.io/debian-stable binary/ | sudo tee \ /etc/apt/sources.list.d/jenkins.list > /dev/null
sudo apt-get update
sudo apt-get install jenkins"

Now start or enable the service of Jenkins.
"Sudo systemctl enable jenkins"

Go to your instance and open port number 8080 for Jenkins.

Once you open the port for Jenkins use the Public IP address of your instance to run the Jenkins on the web.
e.g., http://43.205.103.67:8080/

Use the path which is showing in the picture for the Administrator password.
/var/lib/jenkins/secrets/initialAdminPassword
enter the password in the Administrator password.
Once you entered the password in the Administrator password below page is open and then just click on Install Suggested Plugins.

"JENKINS INSTALLATION PROCESS IS DONE"
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

1. Create a job as Node-todo-app

Paste your GitHub repository URL in the Repository URL of Git.

2. Clone your GitHub repository in your local system so that you can make changes in that and able to push it on your GitHub account.
For the Cloning repo in the Ubuntu machine use the below command.
"Git clone https://github.com/nileshgan/node-todo-cicd.git"

Now link your project with the help of GitHub Webhook.
Go to the GitHub Repository ---> Setting ---> Webhook ---> Add Webhook

Add Webhook as shown in the above picture.

Now just tick on the GitHub hook trigger for GITScm polling.

Add some build steps in the Execute shell command prompt as shown in the above picture and save it.
Before this, you have to install docker-compose.

"docker-compose down
docker-compose up -d --no-deps --build web
echo "Code successfully Done"

This shell script will first down the running container and then create a new container which is specified in Dockerfile. On that container, your application will be running.

Modify some changes in the Node todo app file and push it, then Jenkins will automatically trigger the job.

OutPut:-

----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------