Jenkins Freestyle Project for DevOps Engineers (Part 2)
Jenkins Freestyle Project for DevOps Engineers (Part 2)
What is CI/CD?
Continuous integration and continuous delivery or deployment are like supercharged helpers for software development. They automate different stages of the software creation journey, handling bug fixes and speedy updates, while also keeping things organized across various environments like development, testing, staging, and the big leagues: production.
In the CI part of things, when developers add new stuff to the source code, the system snags that code and gets it ready for action. It sets up all the necessary bits, builds the final product, runs some tests to make sure it’s good to go, and then packages it up neatly.
Once that's done, CD steps in to take this polished creation and send it off to its various destinations—different stages of testing and deployment. This whole process keeps on chugging along, making sure everything's running smoothly and continuously.
What Is a Build Job?
Within Jenkins, a build job is essentially a set of instructions that automate a particular job or phase within the app-building journey. This can involve various tasks like rounding up dependencies, compiling code, storing or changing code, and finally, putting it to the test and sending it off to different places.
Jenkins is pretty versatile, offering different types of build jobs to suit different needs. There are freestyle projects, pipelines, multi-configuration projects, folders to organize stuff, multibranch pipelines, and organization folders, all serving different purposes in the building process.
What is Freestyle Projects ??
A freestyle project in Jenkins is a type of project that allows you to build, test, and deploy software using a variety of different options and configurations. Here are a few tasks that you could complete when working with a freestyle project in Jenkins
Task-01
Step 1: To create an agent for your app.
📌To create an agent we have created a new instance and will use it as an agent on that new machine will copy id-rsa.pub key from the master server to authorized_keys.
Now , we can able to communicate with Jenkins-Server & Agent Server.
Also install java with the latest version @Agent Server no need to install Jenkins @Master Server
on the other hand we can setup an agent on Jenkins Master server (UI).
Click on Setup agent.
Give the Node name
So Below Remote directory is which we had created @Agent server so all work would be save over there.
In the Host tab we have to put agent server public IP address
In credentials click add button
Selects the Jenkins
In username and password select
Then go to the Master server & copy the private key from the server.
Click on enter directly and put the private key of the Master Server
Click on dev-server
I have tried multiple times over here and the error appear.
There must be an issue with the key so again we can go to master and create a key ED25119.
Then we have to put the ed-key.pub to the Agent server in authorized_keys.
Then we have to copy the private key from the Master server and put it on Jenkins credentials.
Click on Update
Post execution of job we can see the log as below.
Task 2:
Create a new Jenkins freestyle project for your app.
In the "Build" section of the project, add a build step to run the "docker build" command to build the image for the container.
Add a second step to run the "docker run" command to start a container using the image created in step 3.
-Solution-
for the above task, we will keep our source code (todo-app) in GitHub repository.
now we build a fresh pipeline with free-style and provide
GitHub details
Agent Details
Run pipeline and check our code is successfully deployed and able to access through web page.
Our code has been deployed over Jenkins-agent we can navigate using public ip:8000
Our pipeline successfully created images and containers in the agent workspace we can verify the same.
Thank You !!
Happy Learning!!