CI/CD Overview and Jenkins
Short and brief documentation on Continuous Integration and Continuous Deployment
What is CI/CD and why do we need it?
Continuous Integration/Continuous Deployment (CI/CD) is an automated methodology used in Software Development Life Cycle (SDLC) to develop our software with less effort and more frequently.
It is a continuous process to build software.
Before CI/CD -
When there was no concept of CI/CD the development and debugging code was taking longer than usual. Let's say the group of developers wrote the code for the entire application all at once which took a week and then pushed it to the but the testing team took a lot of time and by the time they finish testing the developer started working on other projects. In case the testing team found some bugs then it causes a problem it's because they won't get the same team to debug and fix the code which may affect the delivery of software. It will be costly to hire a new team and many more risks can come across.
There were no systems or processes that build and test the code right after the development. That's where CI/CD software such as Jenkins comes into the picture.
After CI/CD -
CI/CD brings a revolution in the DevOps industry. That boosted software development like anything. We create a pipeline using CI/CD tool that automates our tasks such as coding, testing, building etc. and establish a CI Server.
Let's say developers wrote the code and pushed it to Repository, CI server pulls the code automatically once it detects some changes in Repository and starts building and testing the code as configured. If the code builds and tests successfully it will be stored or moved for deployment otherwise it will be notified in case any error or problem is found.
Pipeline
A continuous process of flow of performing some task in a queue.
It is based on the FIFO queue(First Come First Out)
It tells what step to take after the end of the current task.
Refer to the pipeline picture
Developers pushed the code to a version control system such as GitHub or Gibucket.
From the version control system, the CI Server will take the role and operate in the manner it was configured.
The operation will be performed in phases
If in any phase any problem is encountered it will be notified immediately to the developers or the concerned team.
Jenkins
When a project is started, it consists of different phases they are -
This is an infinite continuous process to nourish the product. To make this process automated to improve our performance in software development we use CI/CD tools such as Jenkins which we configure to automate all the phases of DevOps.
In case we are not using such tools then we have to use manpower to complete those tasks of that phases separately with a team and for so tools as well. That's time-consuming and costly as well, such as for planning and coding we use GitHub or sublime, for building the code we use Maven or Gradle, for testing we use Selenium, Deploying and Operating we can use Chef or Puppet and for Monitor, we use Nagia's tool.
To automate all those at once we use CI/CD Tools such as Jenkins where all the phases are controlled by Jenkins itself we just need to deliver the code and the rest will be done by Jenkins.
Jenkins is an integration tool that performs all the tasks like planning, building, testing etc. automatically in the way it is confirmed.
We can even break if we want to do some task manually for example testing or deploying.
Jenkins is open source that's why it's a famous and mostly used CI/CD tool by enterprises.
There are other tools as well - Bamboo, Trans CI, etc.
It helps in automating the entire life cycle of software development.
Jenkins is written in Java, to run Jenkins we must have Java installed on our machine.
Jenkins is OS independent - It can be run on any machine Windows, Linux, MacOS
It supports a lot of plugins and has a large community. Originally developed by SUN microsystem in 2004 under the project Hudson.
The project was later named Jenkins when Oracle occupied SUN Microsystem.
Workflow Of Jenkins
We can attach Git, Maven, Selenium and artifactory plugins to Jenkins.
Once the developer pushes the code on the repository, Jenkins pulls the code and sends it to maven for building.
Once the build is done, Jenkins pulls the code and send it for testing, similarly for quality assurance or satisfaction purpose. In case any problem arises it will be notified immediately to the developers.
We can also deploy using Jenkins tools.
Advantage Of Jenkins
It is GUI based
Rich in plugins due to open source
Can write our plugins or use a Community plugin
Jenkins is not just a tool it's a framework i.e., you can do whatever you want.
It works faster due to master-slave architecture
We can attach slaves (nodes) to Jenkins master. It instructs other slaves to do their job.
If the slave is/are not available, Jenkins itself does a job.
Jenkins also behave as a crone server replacement i.e. can do schedule task.
It can create a label
Master Slave Concept - Jenkins
Jenkins uses a master-Slave architecture
Initially Jenkins use the master to perform tasks.
To load balance all jobs we use slaves
If we have multiple jobs and a master-slave where we have no guarantee who will execute the job (whether master or slave) unless we label our job with the slave's name.
To connect the slave directory with slaves it uses a JAR file called agent.jar. Let's say we have a job with a label called Label1 i.e., it is performed by a slave called/labeled Label1.