Day 23 - 90daysofdevops: Jenkins Freestyle Project for DevOps Engineers.?????

Day 23 - 90daysofdevops: Jenkins Freestyle Project for DevOps Engineers.????

What is CI/CD?

CI/CD, which stands for Continuous Integration and Continuous Delivery, is a software development approach that aims to deliver software quickly and reliably. It involves a series of automated processes that are triggered whenever code is changed.

Continuous Integration :

Continuous Integration (CI) is the practice of merging all code changes from multiple contributors into a shared repository multiple times per day. This ensures that any errors are detected and corrected quickly, and that the codebase is always in a deployable state.

Continuous Delivery :

Continuous Delivery (CD) is the practice of automatically building, testing, and deploying software to production. This means that code changes can be released to production quickly and without manual intervention.

Tools for CICD :

There are many tools available for CICD, including:

  • Jenkins: Jenkins is an open-source CI/CD server that can be used to automate the build, test, and deploy process.
  • GitLab CI/CD: GitLab CI/CD is a CI/CD pipeline that is built into the GitLab platform.
  • CircleCI: CircleCI is a cloud-based CI/CD platform that can be used to automate the build, test, and deploy process.

What Is a Build Job?

A build job is an automated process that compiles, tests, and packages software code. It is a fundamental element of continuous integration and continuous delivery (CICD) pipelines, enabling developers to build and test their code frequently and reliably.

Key Characteristics of a Build Job:

  1. Automation: Build jobs are automated, meaning they run without manual intervention. This automation ensures consistency and efficiency in the build process, reducing the risk of human error.
  2. Code Compilation: Build jobs compile source code into a machine-readable format, such as an executable file or bytecode. This compilation process transforms the human-readable code into a form that can be executed by the computer.
  3. Code Testing: Build jobs typically include unit tests, integration tests, and other types of automated testing to ensure that the code is functioning correctly and meeting the desired requirements.
  4. Code Packaging: Build jobs often package the compiled code into a distributable format, such as a package or container image. This packaging facilitates easy deployment of the software to different environments.
  5. Triggered by Code Changes: Build jobs are typically triggered whenever there are changes to the source code. This ensures that the code is always tested and built after any modifications, preventing potential issues from going undetected.

Types of Build Jobs:

  1. Full Build: A full build compiles and tests the entire codebase, providing a comprehensive assessment of the software's health.
  2. Incremental Build: An incremental build only compiles and tests the changed portions of the codebase, focusing on the updated code and reducing build time.
  3. Release Build: A release build produces a final, deployable version of the software that is ready for distribution to users.
  4. Integration Build: An integration build verifies that different components of the software integrate correctly, ensuring that the overall system functions as intended.


Task-01

  • create a agent for your app. ( which you deployed from docker in earlier task)
  • 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.

STEP - 1

Click on (New_item) then you will enter into Free Style project.

Free Style Project

Give the name Free Style project Name(node-todo-cicd).

Free Style Project Name
General :
Source Code Management :
Build Step : Execute Shell
Build is Done

if Permission related error come follow below steps:

permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post "https://%2Fvar%2Frun%2Fdocker.sock/v1.24/build?buildargs=%7B%7D& Like this .

Add User to Docker Group: Add your user to the docker group, which should have the necessary permissions to access the Docker daemon socket. Run the following command:

sudo usermod -aG docker $USER        

  • After running this command, you may need to log out and log back in, or restart your system for the changes to take effect.
  • Check Docker Daemon Socket Permissions: Verify the permissions of the Docker daemon socket file. Run:

ls -l /var/run/docker.sock
        

  • Restart Docker: After making any changes, restart the Docker service to apply the changes:

sudo service docker restart

reboot
        

The produced image and container are visible. Additionally, a GitHub project was deployed to an Ubuntu EC2 instance at /var/lib/jenkins/workspace/jenkins-project-name.

Build the project.

After a build is completed, you can view the console output.

This is the Final Step But you have to set Allow or deny for Port and ip addresses in EC2 instance for login to this app.

Task-02

  • 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.

First Step install Docker compose :


docker-compose file
General Configuration
docker command for docker-compose

Update the build step as per docker-compose.

Build the project.

After a build is completed, you can view the console output.














要查看或添加评论,请登录

Prakash Bohara的更多文章

社区洞察

其他会员也浏览了