What is CI/CD?
Before we dive into the details of Jenkins Freestyle Projects, let's understand Continuous Integration (CI) and Continuous Delivery (CD). CI involves automating the process of integrating code changes from various developers into a single codebase. This helps in finding bugs, improving software quality, and speeding up feature updates.
Following CI/CD ensures fast and error-free releases to customers by conducting integration and regression tests in staging environments similar to production setups. The main aim is to automate the release process and keep the product deployment-ready at all times.
Wat Is a Build Job?
At the core of Jenkins lies the concept of build jobs, which contain configurations for automating specific tasks in the application building process. These tasks include gathering dependencies, compiling code, running tests, and deploying across different environments.
Jenkins provides various types of build jobs, such as freestyle projects, pipelines, multi-configuration projects, and organizational folders.
Task-01 : Setting up an Agent for Your App
Step 1: Log in to your Jenkins server.
-
Step 2: Go to the dashboard and click on "Manage Jenkins" to set up an agent.
-
Step 3: Provide a name for your agent and create it.
-
Step 4: Fill in the required details for your agent and save it.
Your agent is now created.
-
Next, activate your agent from the remote directory.
Now, our agent is connected.
Now, create a new Jenkins freestyle project for your application.
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.
Save the pipeline and click on "Build Now."
Congratulations! Your pipeline is now working.
Let's move on to Task-02:
Task-02: Creating a Jenkins Project for Docker Compose
- 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)
Step 1: Create a freestyle pipeline named "docker-compose-job" and save it.
Step2: Click on "Execute shell" under build steps.
Step3: Then, add the build steps in the pipeline and save it.
Step4: Click on "Build Now."
Step5: Your pipeline is now running.
- 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.
Thank you for reading! ๐