Continuous Integration is a process in which all the development work will be integration as early as possible. The resulting artefacts are automatically created and tested. In this blog will help you the continues integration Jenkins with Slack and Email Notification, In order to notify developer each and every build on the slack channel and also if any build failed you will be notified in your mail.
Jenkins CI With Slack And Email Notification
1. Introduction
Jenkins is an open-source continuous integration software tool which is written in Java for testing & reporting the isolated changes in larger code basis in real-time project. This is the software that enable developer to find the defects and solve it rapidly via automation testing.
2. Create Slack Account
Well Slack is charting software. Slack has provides a hooks, which helps to provide communication to your team members. Here are integrating Jenkins, so it can sends all the latest build notification into your slack Channel. So, If you haven't created your slack account till now, You can visit the below link -
curl -X POST --data-urlencode "payload={\"channel\": \"#codeztech-jenkins\", \"username\": \"webhookbot\", \"text\": \"This is posted to #codeztech-jenkins and comes from a bot named webhookbot.\", \"icon_emoji\": \":ghost:\"}" https://hooks.slack.com/services/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
Details please check the below Screen Shot -
Slack Webhook URL
3. Configure Slack Notification Plugin in Jenkins
Make sure You have installed Slack Notification Plugin from Jenkins Manage Plugin. Please install the Lower version such as 2.20. If you don't know where to install version 2.2o plugin, please visit and download from the below link -
Once you have done that, go to Manage Jenkins -> Upload This Plugin and Restart your Jenkins. I have made a complete video on that, I am attaching it in the below this blog. Feel free to comment on my Youtube channel or this blog, if you have any issue.
Once you have done that, Go to Manage Jenkins - > Configure System.
Your Base URL will be always - https://hooks.slack.com/services/
Team SubDomain - Will be Your - Channel Name -- You will get it from your URL path like
Slack - Incoming WebHook Team Sub Domain
Add the credential and provide your channel name adding to # . Like where you are planing to send all the build notification. Click on Test Connection in order to whether the current setup is working properly or not.
Configure Slack On Jenkins
4. Configure Email Notification in Jenkins
In order to configure email notification in Jenkins We need to follow the below steps -
SMTP Server - smtp.gmail.com
Default Email - @gmail.com
Check on the SMTP Authentication
Username - youremailId
Password -
Dont put your gmail password. Google won't allow that. what you have to Dont
Step 1 - Login to your gmail -> Go to manage your account
Step 2 - Click on the security tab -> Singing in to Google
Step 3 - Click on App password -> Select the Device you want to generate the password
A Jenkins project is a repeatable build which contains steps and post build actions. The type of action you can perform beginning of build step or post build action. There are many standard plugin are available with in a Jenkins free style project to help you to overcome your problem.
Jenkins create & build free style project
1. Free Style Project in Jenkins
A Jenkins project is contains steps and post build actions. The type of action we can perform in order to build step, post-build action or Jenkins pipeline. There are tons of standard plugin available in Jenkins to overcome our problem.
2. Jenkins - Creating Free Style build Job
For Creating the Jenkins free style job, we have to login to our Jenkins Dashboard. If it is hosted locally please visit http://localhost:8080 If you hosted some the URL visit over there.
Step - 1
Click on the new Item, top left corner of your dashboard -
Jenkins NewItem
Step - 2
Enter the name of the item, choose freestyle project and click on ok.
Freestyle Project
Step - 3
Enter the details of the project you want to set.
Jenkins Project Details
Step - 4
Under the source code management please enter your repo URL. In order to clone your repository and run it. Your url can be - https://github.com/kriru/firstJava.git
Jenkins Setup Git Project
Step - 5
Next click on Add build step - > Execute Windows batch command and add the command you want to execute, Our case -
javac HelloWorld.java
java HelloWorld
Jenkins Build Windows Batch Command
Step - 6
After that click on apply & Save - > Build now, in order to check whether the build is successful or not.
Jenkins Build Now
Jenkins Build Successful
Step - 7
If you want to explore it more you can click on console output to see the details result.
Jenkins console output
Congratulations, we have executed our HelloWorld program from Jenkins.
Jenkins is anopen source automation server. which help to automate the non human part of software development process with continuous integration, continuous delivery and continuous deployment. It a server based system, which runs servlet container such as apache tomcat.
Jenkins - Installation of Jenkins
1. Overview
Jenkins is an open-source automation tool developed by sun microsystem and written in Java. Initial released date was 2nd february 2011. Jenkins offers continuous integration with continuous delivery and continuous deployment pipeline. Jenkins setup is also breeze due to java based construction. It is ready to play right out of the box & works well with windows, Mac OS X, Linux and Ubuntu.
In this tutorial we will walk you through steps of installing Jenkins on a Linux operating system.
2. Hardware Requirements
We need minimum 256 mb of RAM in order to install Jenkins on computer.
1 GB hard drive space
3. Software Requirements
Since Jenkins developed by sun microsystem and written in Java. We have to make sure about that Java is Installed in our system. In order to see whether Java is installed or not, we can say from terminal or command prompt -
java -version
openjdk version "12.0.1" 2019-04-16
OpenJDK Runtime Environment (build 12.0.1+12)
OpenJDK 64-Bit Server VM
If it is not yet installed then -
# install java 1.8 on Amazon Linux
sudo yum update -y
sudo yum install -y java-1.8.0-openjdk-devel
sudo alternatives --config java
4. Install Jenkins on Linux Operating System
For installation of Jenkins on linux operating system please follow up the below steps -
If you are installing Jenkins in Amazon Cloud server, while connecting to EC2 server make sure you have followed the below steps, or else you won't be able to connect -
# ssh into EC2 instance
ls -lah /path/jenkins-key.pem
chmod 400 /path/jenkins-key.pem
ssh -i /path/jenkins-key.pem
ec2-user@ec2-123-456-78-9.compute-1.amazonaws.com
Once your installation is done please start and enable your Jenkins service by saying -
# start Jenkins at boot time
sudo systemctl start jenkins.service
sudo systemctl enable jenkins.service
If you want to restart your Jenkins please follow below steps -
#Restart Jenkins
sudo /etc/init.d/jenkins restart
Make sure you have installed git if you are dealing with cloning repository from bitbucket or Github or any other platform -
# install git
sudo yum install git
5. Install Jenkins on RPM Distros Operating System
For installation of Jenkins on rpm distros please follow up the below steps -
# Add yum repo and install Jenkins
sudo wget -O /etc/yum.repos.d/jenkins.repo
http://pkg.jenkins-ci.org/redhat-stable/
jenkins.repo
sudo rpm --import
http://pkg.jenkins-ci.org/
redhat-stable/jenkins-ci.org.key
sudo yum install jenkins
Once your installation is done please start and enable your Jenkins service by saying -
# Start Jenkins at boot time
sudo systemctl start jenkins.service
sudo systemctl enable jenkins.service
If you want to restart your Jenkins please follow below steps -
#Restart Jenkins
sudo /etc/init.d/jenkins restart
6. Install Jenkins on Ubuntu Operating System
For installation of Jenkins on ubuntu please followup the below steps -
Amazon EC2 is one of the most used and most basic services in Amazons so it makes sense to start with EC2 when you are new to AWS. But the first question is that what is EC2 in AWS ?
AMAZON EC2 HOSTING MEAN STACK APPLICATION
1. What is EC2 in AWS ?
Well to be very simple,
It's basically virtual machine which includes CPU, RAM, ROM e.t.c
It also allows to choose different platform ( like windows, linux, ubuntu e.t.c ) while you are launching virtual machine in cloud.
The Virtual machine we called it as an instance, you can easily start, stop or terminate your instance.
2. AWS EC2 Mean Stack Application Screens?
I am sharing few screens about out Mean Stack Applications that we are going to host it in AWS EC2.
Insert -
Mean Stack CRUD Application Insert
Update -
Mean Stack CRUD Application Update
Delete -
Mean Stack CRUD Application Delete
3. Architecture of the Mean Stack Application
In the below diagram, this is the architecture of our mean stack application that we are going to setting up in 2 AWS instance. In the FrontEnd Part I am using Angular 6, and
MEAN STACK APPLICATION ARCHITECTURE
whatever user interaction got happened like create, read, write and delete it's happening from Node JS. So Node Js is act as a mediator which helps to talk to my database mongo DB and get back the data to frontend. So we will be going to use 2 instance 1 for frontend and 1 for backend.
3. AWS EC2 Hosting Mean Stack Application using PM2 -
This is the other ubuntu Instance that we are launching it. First thing we need to install Node JS, Angular 6, NVM and PM2 in the AWS EC2 instance. Then we have to clone the code inside the EC2 instance.
git clone https://atique12@bitbucket.org/atique12/mongocrud_application_back_end.git Then edit the file - Mean Stack BackEnd Project - db.js and index.js - Instead of Localhost put first instance mongo DB EC2 Public ip to db.js and 2nd instance public ip to 2nd EC2 instance. Mean Stack FrontEnd Project - Inside src/app/shared vi person.services.ts Change localhost to 2nd AWS EC@ public ip. You can also Visit my youtube video for more details -
Thank you guyz.
Please don't forgot to subscribe my youtube channel.