Day 8 : Jenkins: Automating Your Software Delivery Pipeline โœจ๐Ÿš€ Part 1

Day 8 : Jenkins: Automating Your Software Delivery Pipeline โœจ๐Ÿš€ Part 1

ยท

2 min read

Jenkins is a powerful open-source automation tool that enables Continuous Integration (CI) and Continuous Delivery (CD) of software projects. It streamlines the software development process by automating repetitive tasks and providing a framework for building, testing, and deploying code changes. Here's a step-by-step guide to setting up Jenkins for your project:

Installation and Setup ๐Ÿ› ๏ธ๐Ÿ”ง

  1. Update package list:

     sudo apt update
    
  2. Install OpenJDK 17 (Java Runtime Environment):

     sudo apt install openjdk-17-jre
    
  3. Check Java version:

     java -version
    
  4. Add Jenkins repository key and source to package manager:

     curl -fsSL https://pkg.jenkins.io/debian/jenkins.io-2023.key | sudo tee /usr/share/keyrings/jenkins-keyring.asc > /dev/null
     echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/null
     sudo apt-get update
    
  5. Install Jenkins:

     sudo apt-get install jenkins
    
  6. Check Jenkins status:

     systemctl status jenkins
    
  7. Retrieve the initial admin password:

     sudo cat /var/lib/jenkins/secrets/initialAdminPassword
    
  8. Access Jenkins on your browser and follow the setup wizard.

Docker Integration ๐Ÿณ

Install Docker:

  1.  sudo apt install docker.io
    
  2. Add Jenkins to the Docker group:

     sudo usermod -aG docker jenkins
    
  3. Restart Jenkins:

     sudo systemctl restart jenkins
    

Creating a Basic Pipeline ๐Ÿš€๐Ÿ”

  1. Create a new pipeline job:

    • Name: YourJobName

    • Type: Pipeline

  2. Configure the pipeline stages:

     pipeline {
        agent any
        stages {
           stage("Code") {
              steps {
                 echo "Code Cloned"
              }
           }
           stage("Build") {
              steps {
                 echo "Code Built"
              }
           }
           stage("Test") {
              steps {
                 echo "Code Tested"
              }
           }
           stage("Deploy") {
              steps {
                 echo "Code Deployed"
              }
           }
        }
     }
    
  3. Save and run the pipeline job.

Troubleshooting ๐Ÿ› ๏ธ๐Ÿ”

  • Check ports in use:

      sudo lsof -i:8001
    
  • Using Docker Compose:

      docker-compose down
      docker-compose up -d
    

Benefits of Jenkins Pipelines ๐Ÿ’ก๐ŸŒ

  • Automation: Jenkins automates repetitive tasks, reducing manual errors.

  • Speed: Continuous Integration shortens feedback loops, accelerating development.

  • Reliability: Automated testing ensures code quality and stability.

  • Consistency: Pipelines enforce consistent processes across teams.

  • Traceability: Each pipeline run is recorded, aiding troubleshooting and audits.

Conclusion ๐ŸŽ‰๐Ÿš€

With Jenkins, you can build, test, and deploy software efficiently and reliably. By setting up pipelines, you establish a structured approach to software delivery, enhancing collaboration and quality. Embrace Jenkins to streamline your development lifecycle and deliver outstanding software with confidence! ๐ŸŒŸ๐Ÿš€

ย