🛠Day-22 : Getting Started with Jenkins

🛠Day-22 : Getting Started with Jenkins

🤵What is Jenkins?

  • Jenkins is an open source continuous integration-continuous delivery and deployment (CI/CD) automation software tool written in the Java programming language. It is used to implement CI/CD workflows, called pipelines.

  • It allows all the developers to automate build, test and deploy process of software.

  • Jenkins achieves Continuous Integration with the help of plugins. Plugins allow the integration of Various DevOps stages. If you want to integrate a particular tool, you need to install the plugins for that tool.

✨Let us do discuss the necessity of this tool before going ahead to the procedural part for installation:

  1. Automation of Software Development Processes: Jenkins is a powerful automation tool primarily used for continuous integration and continuous delivery or deployment (CI/CD). It automates various stages of the software development lifecycle, including building, testing, and deploying applications. By automating these processes, Jenkins helps in reducing manual errors, improving efficiency, and speeding up the overall development cycle.

  2. Integration with Various Tools and Technologies: Jenkins provides extensive support for integrating with a wide range of tools and technologies used in modern software development, such as version control systems (e.g., Git, SVN), build tools (e.g., Maven, Gradle), testing frameworks, deployment tools, and more.

  3. Continuous Integration and Testing: Jenkins enables continuous integration practices by automatically triggering builds and running tests whenever changes are committed to the version control repository. This ensures early detection of integration issues and bugs, leading to faster feedback loops and higher software quality.

  4. Streamlined Deployment Process: With Jenkins, teams can automate the deployment process, ensuring consistent and reliable deployments across different environments (e.g., development, staging, production).

  5. Scalability: Jenkins can be scaled horizontally to handle large CI/CD workloads by distributing build jobs across multiple nodes. This scalability ensures that Jenkins can support the growth of your development team and projects.

  6. Customization: Jenkins is highly customizable through its plugins and support for defining pipelines as code. This allows you to tailor Jenkins to fit your specific development and deployment requirements.

    Jenkins is a crucial tool for modern software development teams seeking to automate and streamline their CI/CD pipelines. By facilitating automation, integration, testing, deployment, scalability, and visibility, Jenkins helps teams deliver high-quality software faster and more efficiently, ultimately enhancing the overall development process and delivering greater value to end-users.

✔Task 1: What you understood in Jenkins?

Jenkins is an automation server essential for modern software development. It enables continuous integration (CI) and deployment (CD), automating tasks like building, testing, and deploying code. Jenkins' key strength lies in its ability to create pipelines, defining the entire software delivery process as code. This automation helps teams catch bugs early, improve code quality, and accelerate software delivery. Jenkins is highly extensible, supporting integration with various tools and technologies through plugins. It empowers teams to build, test, and deploy software efficiently, making it a must-have for any development team striving for productivity and quality.

✔Task 2: Create a freestyle pipeline to print "Hello World!!

Step 1: First of all create a AWS EC2 instance and connect that instance with your Local machine using SSH client.

Step 2: For running jenkins You must have java install in your instance for that we will install java first.and after installing will check version using java version.

sudo apt update
sudo apt install fontconfig openjdk-17-jre
java -version
openjdk version "17.0.8" 2023-07-18
OpenJDK Runtime Environment (build 17.0.8+7-Debian-1deb12u1)
OpenJDK 64-Bit Server VM (build 17.0.8+7-Debian-1deb12u1, mixed mode, sharing)

Step 3: After the installation of Java version 17 will install jenkins LTS release for Ubuntu because we are using AMI as Ubuntu, and prefer to install stable version as weekly release can have updates, below Commands used to install.

sudo wget -O /usr/share/keyrings/jenkins-keyring.asc \
  https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
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
sudo apt-get update
sudo apt-get install jenkins

Step 4: To check jenkins active or not will use command, after doing that we have to copy the public url of instance and run it using :8080 but it will not run as we have not added port 8080 to security group.

systemctl status jenkins #it will show active means jenkins is up now on port 8080

Step 5: Go to Security group, edit inbound rules add custom TCP Select Port range 8080 & anywhere-IPv4 Save it. Now it will work on this port

Step 6: Access your Jenkins through your-public-IP: 8080
will get Jenkins dashboard,Initially jenkins is locked you have to copy the given path and paste it to your Local machine using Command sudo cat <path> this will show you a password copy and paste it in the dashboard and continue.

Step 7: You will see Jenkins Dashboard go for Create a Job Option and enter a Item name -> HelloWorld-Pipeline and select Free style Project.

Step 8: Configure the Job

  1. In the job configuration page, go to the "Build" section.

  2. Click on "Add build step" and select "Execute shell".

  3. In the command box, type echo "Hello World!!".

  4. Save the Job Configuration.

    Step 9: Run the Job.

    1. Click on "Build Now" to run the job.

    2. Jenkins will execute the pipeline and print "Hello World!!" in the console output.

🚧Conclusion

Jenkins is a powerful and widely-used automation server that greatly facilitates the continuous integration and continuous delivery (CI/CD) process for software development teams. With its extensive plugin ecosystem, Jenkins offers flexibility and customization to suit various project requirements. By automating repetitive tasks such as building, testing, and deployment, Jenkins helps teams increase productivity, improve software quality, and accelerate the delivery of software updates. Its user-friendly interface, robust community support, and seamless integration with other development tools make Jenkins an indispensable tool for modern software development workflows.

Did you find this article valuable?

Support Vivek Ashok Moudekar by becoming a sponsor. Any amount is appreciated!

Â