Setting Up Jenkins & Creating Your First Pipeline😃

Deepesh GuptaDeepesh Gupta
3 min read

Day 24: Setting Up Jenkins & Creating Your First Pipeline😃

Today, we’ll be focusing on installing and configuring Jenkins on our systems. Additionally, we’ll take on an exciting challenge—creating a freestyle pipeline to apply what we've learned. Ready to enhance your automation skills? Let’s get started! 💻🔧

Setting Up Jenkins

Prerequisites:

  • Minimum hardware requirements:

    • 256 MB of RAM

    • 1 GB of drive space (10 GB recommended if running Jenkins as a Docker container)

  • Java 11 or 17 is required.

Installing Jenkins:

  1. Update the Packages:

       sudo apt-get update
    
  2. Install Java:

       sudo apt install openjdk-11-jre
    
  3. Check Java Installation successful or not:

       java --version
    
  4. Add Jenkins Repository Key:

       curl -fsSL https://pkg.jenkins.io/debian/jenkins.io-2023.key | sudo tee /usr/share/keyrings/jenkins-keyring.asc > /dev/null
    
  5. Add Jenkins Repository:

       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
    
  6. Update Package Lists and Install Jenkins:

       sudo apt-get update
       sudo apt-get install jenkins
    
  7. Start Jenkins:

       sudo systemctl start jenkins
    
  8. Check Jenkins Status:

       systemctl status jenkins
    

  9. Open Port 8080 on your EC2 Instance: Since Jenkins by default runs on port 8080 thus we are allowing this port the permission.

  10. Access Jenkins Web Interface: Open a web browser and enter the public IP address of your EC2 instance followed by :8080(e.g.,http://<your_public_ip>:8080).

    To retrieve the Jenkins initial admin password, enter the following commands in your Linux terminal:

    💡
    /var/lib/jenkins/secrets/initialAdminPassword

    Then, run:

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

    This will generate the admin password required for your first login.

  11. Find Admin Password: Go to the specified Path on your EC2 instance as mentioned above to get Administrator Password.

Customize Jenkins:

Congratulations, your setup is ready and we are ready to use it.

Task: Create a Freestyle Pipeline to Print "Hello World"

  1. Go to New Item on Dashboard on top left.

  2. Enter Item name and select on Freestyle Project and click ok.

  3. Give a description about what your project is about for others to understand easily.

  4. Select "Execute Shell" in Build Steps.

  5. Give the required steps to execute. Since here we only want to print Hello World thus we have only 1 command which is echo command.

  6. Click on Build Now on left to start.

  7. The green tick shows that the project ran successfully.

Console output shows what was the output and thus verifies the success. We finally see the output "Hello World" which we wanted.

Conclusion

In conclusion, Jenkins stands as a cornerstone of modern DevOps practices, providing a robust platform to automate the entire software delivery process. With its powerful pipeline features and extensive plugin ecosystem, Jenkins significantly improves the efficiency and reliability of CI/CD workflows. As emphasized by Deepesh Gupta, embracing Jenkins can elevate your automation skills to new heights! 🚀

0
Subscribe to my newsletter

Read articles from Deepesh Gupta directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Deepesh Gupta
Deepesh Gupta

DevOps & Cloud Enthusiast | Open Source Contributor | Driving Technological Excellence in DevOps and Cloud Solutions