Complete Jenkins CI/CD Project - Continued with Documentation (Day-25)

Complete Jenkins CI/CD Project - Continued with Documentation (Day-25)

🚦Jenkins Components and Terminology:

📌Job: A job is a task that you want Jenkins to perform. It could be building a specific project, running tests, deploying software, etc.

📌Build: A build is a process of transforming source code into a deployable software artifact. This can involve compiling code, running tests, and creating executable files.

📌Pipeline: A pipeline is a series of steps that define the process of building, testing, and deploying software. Jenkins pipelines can be written using code, often using a tool called "Jenkinsfile."

📌Jenkinsfile: A Jenkinsfile is a text file that contains the definition of a pipeline using a domain-specific language. It's like a script that tells Jenkins what to do at each step of the pipeline.

📌Stage: A stage in a pipeline is a distinct part of the process, like "Build," "Test," or "Deploy." Pipelines are divided into stages to organize the workflow and make it easier to understand.

📌Node/Agent: A node (also called an agent) is a machine that Jenkins uses to execute tasks. It can be a physical server, a virtual machine, or even a container.

📌Master: The Jenkins master is the main control hub. It's the part of Jenkins that manages all the nodes, schedules jobs, and coordinates the overall workflow.

📌Trigger: A trigger is an event that starts a Jenkins job. It could be a code commit, a scheduled time, or some other condition.

📌Plugin: Jenkins is highly extensible through plugins. Plugins add extra functionalities to Jenkins, allowing you to integrate it with various tools, services, and technologies.

📌SCM (Source Code Management): SCM refers to tools like Git, SVN, and others that help manage and version control the source code of a project.

📌Freestyle Project: A Freestyle Project in Jenkins is a type of project configuration that allows you to define a series of build steps and actions using a UI. It's a traditional approach where you can specify individual build steps, such as code checkout, compiling, testing, and deployment, by configuring them through the Jenkins UI. Each step is executed sequentially, and you have flexibility in defining the order and configuration of these steps. It's akin to composing a custom workflow by selecting and arranging building blocks tailored to the project's requirements.

📌Pipeline: A Pipeline in Jenkins, often referred to as "Jenkins Pipeline," is a suite of plugins that provides a way to define software delivery workflows as code. It offers a powerful and programmable approach to defining the entire software lifecycle as a series of stages and steps. Pipelines are typically defined using a domain-specific language, such as the Groovy-based "Jenkinsfile." This provides a structured and maintainable way to automate end-to-end software delivery processes with repeatability and transparency.

  1. Introduction: Overview of the project and purpose of the documentation.
  • The project "node-todo-cicd" available on GitHub at the repository URL github.com/LondheShubham153/node-todo-cicd... is a demonstration of a Node.js web application integrated with a CI/CD (Continuous Integration/Continuous Deployment) pipeline. The project showcases the automation of building, testing, and deploying a Node.js application using CI/CD principles.
  1. Prerequisites: List of prerequisites, including Jenkins installation and repository setup.
  • Open AWS Account and launch an instance.

  • Shh, it in your terminal and install Jenkins.

  • Install and configure Jenkins on your server or cloud platform by using the below steps.

  • ```python #Step - 1 Install Java #Update your system sudo apt update

    #Install java sudo apt install openjdk-11-jre

    #Validate Installation java -version #It should look something like this

  • #openjdk version "11.0.12" 2021-07-20 OpenJDK Runtime Environment (build 11.0.12+7-post-Debian-2) OpenJDK 64-Bit Server VM (build 11.0.12+7-post-Debian-2, mixed mode, sharing)

    #Step - 2 Install Jenkins

  • #Just copy these commands and paste them onto your terminal. curl -fsSL pkg.jenkins.io/debian-stable/jenkins.io-202.. |

  • sudo tee \ /usr/share/keyrings/jenkins-keyring.asc > /dev/null echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \ pkg.jenkins.io/debian-stable binary/ |

  • sudo tee \ /etc/apt/sources.list.d/jenkins.list > /dev/null

    sudo apt-get update

  • sudo apt-get install jenkins

#Step -3 Start jenkins

sudo systemctl enable jenkins

sudo systemctl start jenkins

sudo systemctl status jenkins

#Step - 4 Unlock jenkins

sudo cat /var/lib/jenkins/secrets/initialAdminPassword ```

  1. Jenkins Job Configuration: Step-by-step guide to creating the Jenkins job.
  • Create a new Jenkins job for your CI/CD pipeline.

  • Enter the name of the job and select the Jenkins Freestyle project for your app.

  • I Forked this github.com/LondheShubham153/node-todo-cicd... repository.

  • Add above repo to GitHub projects.

  • Install necessary plugins to install GitHub integration.

  • Add branch name.

  1. Source Code Integration: Explanation of how the repository is connected to Jenkins.
  • Connect Jenkins to your version control system (e.g., GitHub, GitLab).

  • GitHub repo navigate to settings > webhooks.

  • Click "Add Webhook"
    Enter the payload URL, followed by '/gitHub-webhook/'.
    Select the 'application/JSON'.
    Select the event that should trigger the webhook.

  • Save the webhook configuration.

  • where ever we change and commit the repo it get green tick on the webhook configuration.

  1. Build Stage Configuration: Details on setting up the build stage with required tools.
  • Set up the build stage in your Jenkins job to compile and package your application.

  • In Execute shell add command where Groovy syntax while writing the build script.

  • Ensure that the builds worked successfully.

  • Where ever we change the code from github, the webhook will trigger the jenkins job and starts build automatically.

  1. Test Stage Configuration: Description of integrating automated tests.
  • Integrate automated testing in the Jenkins pipeline to ensure code quality.
  1. Deployment Configuration: Explanation of deploying the application.
  • Set up deployment to your target environment (e.g., staging, production).
  1. Troubleshooting: Common issues and solutions.

    Make sure in your security group inbound rule add jenkins default port no. 8080 and application port no. 8000

  2. Conclusion: Wrap-up of the documentation and future improvements.

    By creating a new Jenkins job for your CI/CD pipeline, you automate the entire process from source code management to deployment, ensuring consistent and reliable software delivery. Jenkins orchestrates these steps based on triggers you define, providing a streamlined and efficient workflow for development and deployment.

Happy Learning :)

If you find my blog valuable, I invite you to like, share, and join the discussion. Your feedback is immensely cherished as it fuels continuous improvement. Let's embark on this transformative DevOps adventure together! 🚀 #devops #90daysofdevop #git&github #jenkins