Day-22 : Getting Started with Jenkins

Day-22 : Getting Started with Jenkins

What is Jenkins?

Jenkins is an open-source automation server that simplifies the software development process. Here's a simple explanation with key points:

  1. Automation: Jenkins automates repetitive tasks like building, testing, and deploying software.

  2. Continuous Integration: It integrates code changes from multiple developers into a shared repository, ensuring early detection of issues.

  3. Continuous Delivery: Jenkins automates the deployment of applications to various environments, making the process faster and more reliable.

  4. Plugin-based: Jenkins offers a wide range of plugins to extend its functionality and integrate with different tools and technologies.

  5. Build Pipelines: It allows the creation of complex pipelines to define and manage the steps involved in the software build and deployment process.

  6. Scalability: Jenkins can scale horizontally to handle larger projects and distributed teams.

  7. User-friendly Interface: Jenkins provides a web-based interface to manage jobs, configure settings, and view build results.

  8. Extensibility: It can be customized and extended using plugins and scripts to meet specific project requirements.

  9. Active Community: Jenkins has a large community that contributes plugins, provides support, and shares best practices.

  10. Open Source: Jenkins is freely available and continuously improved by the community, making it flexible and adaptable for different use cases.

In summary, Jenkins automates and streamlines the software development lifecycle, enabling faster and more efficient delivery of high-quality applications.

To install Jenkins on an EC2 instance with easy understanding, follow these simplified steps:

  1. Launch an EC2 instance: Go to the AWS Management Console, launch an EC2 instance, and choose an appropriate operating system like Ubuntu or Amazon Linux.

  2. Connect to the instance: Use SSH or any preferred method to connect to your EC2 instance.

  3. Update the system: Run the command sudo apt-get update to update the system packages.

  4. Install Java: Jenkins requires Java to run. Install it by running sudo apt-get install default-jdk.

  5. Jenkins Keys: Import the Jenkins GPG key to verify the integrity of Jenkins packages by running the following command:

       curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee \
         /usr/share/keyrings/jenkins-keyring.asc > /dev/null
    
  6. Add Jenkins repository: Add the Jenkins repository to your system by running these commands:

     echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
         https://pkg.jenkins.io/debian-stable binary/ | sudo tee \
         /etc/apt/sources.list.d/jenkins.list > /dev/null
    
  7. Install Jenkins: Run sudo apt-get update to refresh package lists, then install Jenkins with sudo apt-get install jenkins.

  8. Start Jenkins: Start the Jenkins service with sudo systemctl start jenkins.

  9. Enable Jenkins: Enable Jenkins to start automatically on system boot with sudo systemctl enable jenkins.

  10. Access Jenkins: Open a web browser and enter your EC2 instance's public IP address followed by port 8080 in security group.

  11. Unlock Jenkins: On the Jenkins web page, you will be prompted to enter the initial admin password. Retrieve the password from your EC2 instance by running:

    sudo cat /var/lib/jenkins/secrets/initialAdminPassword
    
  12. Follow the setup wizard: Enter the initial admin password on the Jenkins web page and follow the setup wizard to complete the installation. Install recommended plugins and set up an admin user.

  13. Customize Jenkins: Once the setup is complete, you can customize Jenkins by installing additional plugins, configuring global tools, and creating Jenkins jobs.

Remember to refer to the official Jenkins documentation or AWS documentation for detailed instructions tailored to your specific EC2 instance and operating system.


Create a freestyle pipeline to print "Hello World!!"

  1. Click on "New Item" to create a new Jenkins job.

  2. Enter a name for your job, select "Freestyle project", and click "OK".

  3. In the configuration page, scroll down to the "Build" section and click on the "Add build step" dropdown.

  4. Select "Execute shell" from the dropdown.

  5. In the "Command" field, enter the following command:

     echo "Hello World!!"
    
  6. Save your configuration by clicking on "Save" or "Apply".

  7. Now you can run the pipeline by clicking on "Build Now".

  8. Once the job is triggered, Jenkins will execute the shell command and print "Hello World!!" in the console output.


    Thank you for reading. I hope you were able to understand and learn something new from my blog.

    Happy Learning!

    Please follow me on Hashnode and do connect with me on LinkedIn ArnavSingh

Did you find this article valuable?

Support Arnav Singh by becoming a sponsor. Any amount is appreciated!