Day-22 : Getting Started with Jenkins

Vibhuti JainVibhuti Jain
6 min read

What is Jenkins?

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

  • Jenkins is a tool that is used for automation, and it is an open-source server that allows all the developers to build, test and deploy software. It works or runs on java as it is written in java. By using Jenkins we can make a continuous integration of projects(jobs) or end-to-endpoint automation.

Tasks1:

  1. What Jenkins is and why it is used.

Jenkins is an open source automation tool written in Java programming language that allows continuous integration.

Jenkins builds and tests our software projects which continuously making it easier for developers to integrate changes to the project, and making it easier for users to obtain a fresh build.

It also allows us to continuously deliver our software by integrating with a large number of testing and deployment technologies.

Why it is used: Jenkins is used to automate various stages of software development, ensuring that the code is continuously integrated, tested, and delivered, ultimately leading to faster and more reliable software releases.

  1. Reflect on how Jenkins integrates into the DevOps lifecycle and its benefits.

Continuous Integration (CI):

  • Automated Builds: Jenkins automates the process of integrating code changes from multiple developers into a shared repository. Every time code is committed, Jenkins triggers an automated build, compiling the code and running tests to ensure it integrates well with the existing codebase.

  • Early Detection of Issues: By integrating frequently, Jenkins allows teams to catch integration issues early, reducing the risk of significant bugs in the final product. This is crucial in maintaining code quality and ensuring that each new code change is stable and reliable.

Continuous Delivery (CD):

  • Automated Deployment: Jenkins can automate the deployment process, moving code from development to production environments. This includes deploying to various stages, such as staging, QA, and production, ensuring that code is always ready to be released.

  • Version Control and Rollbacks: Jenkins integrates with version control systems to manage deployments, allowing for easy rollbacks in case of failures. This ensures that deployments are smooth and any issues can be mitigated without significant downtime.

Benefits of Jenkins in DevOps

Increased Automation: Jenkins automates repetitive tasks such as builds, tests, and deployments, reducing manual effort and the potential for human error. This leads to faster and more reliable software delivery.

Improved Code Quality: Continuous integration and automated testing ensure that code is regularly tested and validated, leading to higher code quality. Issues are identified and resolved early, reducing the likelihood of defects in the final product.

Enhanced Collaboration: Jenkins promotes collaboration among development, operations, and testing teams. By providing a centralized platform for integrating and testing code, Jenkins ensures that all team members are on the same page and can work together effectively.

Scalability: Jenkins is highly scalable, allowing it to handle large and complex projects with ease. It can manage multiple pipelines and workflows, making it suitable for organizations of all sizes, from small teams to large enterprises.

  1. Discuss the role of Jenkins in automating the build, test, and deployment processes.

Jenkins plays a pivotal role in automating the build, test, and deployment processes within the software development lifecycle. These processes are essential components of continuous integration (CI) and continuous delivery (CD), and Jenkins helps streamline and enhance them through automation.

Automating the Build Process:

Triggering Builds: Jenkins can be configured to automatically trigger builds whenever changes are detected in the version control system (e.g., Git). This ensures that every code change is compiled and built as soon as it is committed.

Build History and Artifacts: Jenkins maintains a history of all builds, including logs and artifacts. This allows developers to review past builds, identify when and where issues were introduced, and retrieve specific versions of the build artifacts if needed.

Parallel Builds: Jenkins can run multiple builds in parallel, which is particularly useful for large projects with multiple branches or components. This speeds up the overall build process and allows for faster feedback.

Automating the Test Process:

Unit Testing: Jenkins can automatically run unit tests after each build, ensuring that the code functions as expected at the individual component level. This helps catch issues early in the development process.

Integration Testing: After unit tests pass, Jenkins can trigger integration tests to ensure that different components of the application work together seamlessly. This is crucial for identifying issues that might not be apparent when testing components in isolation.

Continuous Testing: Jenkins can run tests continuously as part of the CI pipeline, providing immediate feedback to developers when a test fails. This quick feedback loop allows developers to address issues before they become larger problems.

Test Reports: Jenkins generates detailed test reports that provide insights into test coverage, pass/fail rates, and specific errors. These reports are invaluable for understanding the overall health of the codebase.

Automating the Deployment Process:

Automated Deployment Pipelines: Jenkins allows the creation of complex deployment pipelines that automate the entire deployment process, from pushing code to a staging environment to deploying to production. This reduces manual intervention and the risk of human error.

Environment Management: Jenkins can manage multiple environments and ensure that the correct version of the application is deployed to the appropriate environment. This includes handling environment-specific configurations, such as database connections and API keys.

Deployment Notifications: Jenkins can send notifications to the team upon successful or failed deployments, keeping everyone informed and enabling quick responses to any issues that arise.

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

Create a freestyle pipeline in Jenkins that:

  1. Prints "Hello World"

  2. Prints the current date and time

  3. Clones a GitHub repository and lists its contents.

Click on New Item to create a Project.

Give the name of the project, click on new freestyle project.

Add Description of your project and down below you will find build steps option, click on execute shell to write and print hello world.

OUTPUT OF THE FREESTYLE PROJECT:

we can see our project hello world has been created, to run this click on run button or click on Hello world drop down arrow to get build now option to build your project.

To check our output on console, click on (#buildnumber) of last success it will open the console ouput of your project.

In above screenprint we can see Hello printed has printed on console along with date and clone git repository. At the end of the output we can see FINISHED:SUCCESS.

Means our first freestyle project has been successfully completed.

Follow for more updates:)

0
Subscribe to my newsletter

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

Written by

Vibhuti Jain
Vibhuti Jain

Hi, I am Vibhuti Jain. A Devops Tools enthusiastic who keens on learning Devops tools and want to contribute my knowledge to build a community and collaborate with them. I have a acquired a knowledge of Linux, Shell Scripting, Python, Git, GitHub, AWS Cloud and ready to learn a lot more new Devops skills which help me build some real life project.