Today's challenge is particularly exciting as it entails creating a Jenkins Freestyle Project! ๐ ๏ธโจ DevOps enthusiasts, are you ready to unleash your creativity and automation skills? Let's make it happen! ๐
Understanding CI/CD:
Continuous Integration (CI): CI automates code integration from multiple developers into a single codebase. ๐ Frequent commits trigger automated tools for building, reviewing, and improving software quality. It's like having a team of robots streamlining your code collaboration! ๐ค๐
Continuous Delivery (CD): After CI, CD ensures error-free, quick releases. ๐ It automates testing and deployment in staging, guaranteeing a release-ready product for deployment anytime. Your code's journey from creation to deployment becomes a smooth, automated dance! ๐๐ข
The Build Job:
In Jenkins, a build job automates specific tasks in the application building process, such as dependency gathering, compiling, testing, and deploying. ๐๏ธ๐ป Let Jenkins be your code-building assistant, taking care of the nitty-gritty tasks! ๐ค๐ผ
Exploring Freestyle Projects:
A freestyle project in Jenkins is a versatile option for building, testing, and deploying software. Let's walk through two exciting tasks:
Task-01: Building Docker Image for Your App:
๐๏ธ Create an agent for your app (previously deployed via Docker).
- Click on "Set up an agent"
Give Node name, click on Permanent Agent, and click on Create.
Provide remote root directory location give labels to this node and select "Use WebSocket".
Click on save to create an agent and now the agent is created.
๐ Set up a new Jenkins freestyle project.
In the build steps, select "Execute Shell" and add a few commands and now apply and click save.
In the "Build" section, add a step to run "docker build" for image creation. Witness the magic of your code transforming into a containerized masterpiece! ๐ช๐ณ
Add another step to run "docker run" for starting a container using the created image. Watch your app come to life in a Docker container spectacle! ๐๐
Check on the environment
Now check whether build is working, before that we should see whether port 8000 is exposed. (here in task: 18.118.28.103:8000/todos
Task-02: Managing Multiple Containers with Docker-Compose:
- ๐ข Create a Jenkins project to execute "docker-compose up -d" for starting containers (use the day-19 Docker-Compose file).
Create Jenkins project to run "docker-compose up -d" command to start the multiple containers defined in the compose file (Hint: use day-19 Application & Database docker-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: Create a New Jenkins ProjectLog in to your Jenkins dashboard.Click on "New Item" to create a new project.Enter a name for your project, choose "Freestyle project," and click "OK."
Under "General," you can provide a project description.
Under "Source Code Management," select the appropriate option if you're using version control.
- Implement a cleanup step to run "docker-compose down" for stopping and removing defined containers. It's like orchestrating a container symphony! ๐ต๐ข
In the "Build" section, click "Add build step" and choose "Execute shell."
In the shell command box, enter the following command to start the containers using Docker Compose:
echo "code cloned"
docker-compose down
docker-compose up -d --no-deps --build web
echo "code deploy"
Click "Save" to save your Jenkins project configuration.
You can manually run the project by clicking "Build Now" or wait for the configured triggers to initiate the build.
You have successfully created a freestyle Jenkins project !! we explore more on Jenkins in the next articles....