"Automate Your Software Development Process with Jenkins: Understanding CI/CD, Build Jobs, and Freestyle Projects- Create a Delivery Project."
1- What is CI/CD?
CI/CD stands for Continuous Integration/Continuous Delivery (or Continuous Deployment). In simple language, it's a set of practices that helps automate the software development process, from building and testing to deployment.
Continuous Integration (CI) is the practice of frequently integrating small code changes into a shared repository, where automated builds and tests are run to detect and fix issues early on in the development cycle.
Continuous Delivery (CD) or Continuous Deployment, on the other hand, is the practice of automating the deployment of software changes to production in a safe and reliable way. This ensures that new features and bug fixes can be delivered to users quickly and with minimal risk.
In short, CI/CD is all about automating the software development process to improve the quality, speed, and reliability of software delivery.
2- What Is a Build Job?
In Jenkins, a building job is a specific task that involves compiling and testing source code and packaging the final output into a deployable format.
Jenkins is an automation server that helps automate software development tasks, including testing code. A build job in Jenkins typically involves a set of automated steps, including checking out the code from a source code repository, compiling the code, running automated tests, and packaging the final output.
Jenkins allows developers to create, configure, and run build jobs easily and efficiently, using a user-friendly interface. Developers can also customize build jobs by adding plugins, scripts, and other tools to automate the build process and integrate it with other parts of the development workflow.
By using Jenkins build jobs, developers can automate the software development process and ensure that code is properly built, tested, and deployed, saving time and effort and reducing the risk of human error.
3- What are Freestyle Projects?
In Jenkins, a Freestyle project is a type of project that allows developers to create and configure custom-built jobs using a user-friendly interface.
A Freestyle project in Jenkins is highly flexible and customizable, allowing developers to define a series of build steps and actions that are specific to their project requirements. These build steps can include compiling code, running tests, generating reports, and deploying the final output.
In a Freestyle project, developers can also specify various project parameters, such as the location of the source code repository, the built environment, and the type of build tool to use. This allows for a high degree of customization and control over the build process.
-------------TASK-----------
Create a Jenkins freestyle Delivery project:
1- First in your system update and install Java and Jenkins.
2- Now after setting up Jenkins, Create a freestyle job for application delivery.
3- After creating a Job start with adding Configuration steps:
As this, a GitHub project will be adding Github URL and GitHub repository URL.
Select an Execute Shell Script in the Build steps:
4- After saving the configuration, you will see the job has been created.
5- Click on the Build Now option to build the job and you can see the Permalinks and bottom left side that a green tick with the build is created. Right now we are only cloning the git code into our system.
To verify that the git clone is executed. Go to the Terminal cd path/
. you get the path on the console output first line with /var/lib/jenkins/workspace/django-todo-app
6- Now we do some edits to the configuration of the job in the Build step and add commands for a date, user and print happy learning.
As we see it created date and who am I as - Jenkins and printed happy learning.
7- As we have to build containers for the project we have to install Docker and give the Docker user permission to Jenkins as we are building our project using Jenkins. and reboot to update the changes.
Now after the reboot we to log in to Jenkins again is it important to save your username and password?
8- After installing Docker we have to build the Image for the container with the git clone code we have in our system. Edit the build steps in the configuration in Jenkins
Check the console output
9- Now after building the image we will build a container for it by writing a shell script in the build steps in configuration.
Add the port:8001 as we are building the app in this port. In the server security group
Copy the server IP address add 8001 and open we see the application is up and running.
10- Now we build the same application using docker-compose. But first, we have to install docker-compose in our system and kill the existing running container
11- In the git code we have a docker file as well as a docker-compose yaml file. Now we edit the shell script to docker-compose to start.
we use command docker-compose up -d --no-deps -build web
so that it builds with no dependencies and the service name web which is in the docker-compose file
we add docker-compose down
before docker-compose up
as any previous build will get down before building new ones.
As we see #9 is the new docker-compose build
This is the docker-compose yaml file.
As we can see the service name is web and the port expose is 8001
Now the point to be noted is that we can build multiple containers using the docker-compose file by adding another service in the docker-compose file.