Jenkins Freestyle Project for DevOps Engineers
#90 Days of DevOps Challenge - Day 23
What is CI/CD?
CICD Pipelines i.e Continuous Integration, Continuous Delivery and Deployment pipelines, are a way of running Jenkins jobs in a sequence, which resembles a pipeline view.
What are CI/CD Pipelines?
What Is a Build Job?
A Jenkins build job contains the configuration for automating a specific task or step in the application building process. These tasks include gathering dependencies, compiling, archiving, or transforming code, and testing and deploying code in different environments.
Jenkins supports several types of build jobs, such as freestyle projects, pipelines, multi-configuration projects, folders, multibranch pipelines, and organization folders.
What is Freestyle Projects ??
Jenkins freestyle projects allow users to automate simple jobs, such as running tests, creating and packaging applications, producing reports, or executing commands. Freestyle projects are repeatable and contain both build steps and post-build actions.
Task 1:-React Django App
In This Task, we are using React Django App
Step 1:- First we need to create a new item
Step 2:- Now need to give the project name and choose Freestyle project and click on ok
Step 3:- After clicking ok , Need to give the Description and check the GitHub project and need to give GitHub project URL
Step 4:- In Source Code Management choose Git and need to provide the git hub URL and Branch Specifier section, since in the GitHub the code is the main branch so we have to specify the same name
Step 5:- In the Build Step tab, select "Execute Shell" and pass the docker build command Next, pass the docker run command to start a container using the image specified.
echo " $USER Hello i have started my devps journey"
echo "i will build the code using docker"
docker build . -t rect-django-app
echo "i will perfom the test if required"
echo "i will deploy code"
docker run -itd -p 8001:8001 rect-django-app:latest
Step 6:- Now before running the build now we have to make sure that the below commands are installed in the Ubuntu machine
#Below command use to install docker in ubuntu machine
sudo apt-get install docker.io -y
#Below command use to add docker user
sudo usermod -aG docker $USER
#Below command use for rebbot machine
sudo reboot
Step 7:- Now we need to run the Build now
Step 8:- Once the build is successful, you can go to the console output and check the output of the build.
Step 9:- Now we need to verify whether we can browse the application or not by using Public IPv4 address:prot_number
TASK 2:-
Create a Jenkins project to run the "docker-compose up -d" command to start the multiple containers defined in the compose file
Set up a cleanup step in the Jenkins project to run "docker-compose down" command to stop and remove the containers defined in the compose file.
Step 1:- Before running the "docker-compose up -d" file we need to install docker-:- compose in the Ubuntu machine
Step 2:- now need to give the docker-compose command and save and then click on build now
Step 3:- in the console output we can check the output
Step 4:- Now we need to verify whether we can browse the application or not by using Public IPv4 address:prot_number
Thank you for reading!! I hope you find this article helpful!!
if any queries or corrections to be done to this blog please let me know.
Happy Learning!!
Saikat Mukherjee