Getting Started With Jenkins

Deepesh GuptaDeepesh Gupta
5 min read

Introduction to Jenkins!

1. 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.

  • It is used for automation, that allows all the developers to build, test and deploy 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. For example Git, Maven 2 project, Amazon EC2, HTML publisher etc.

    2.Jenkins Architecture Overview 🏗️

    Jenkins follows a master-slave architecture, designed to distribute build and deployment tasks across multiple machines as to reduce and balance the load.

    1. Master Node 🧠:

      • Responsibilities: The Master orchestrates the entire CI/CD pipeline, handling tasks like scheduling jobs, distributing builds to agents/slaves, managing plugin configurations, and reporting build results. So, basically all jobs get created on Master node and is the node where Jenkins gets installed.

      • User Interface: Provides the UI for managing Jenkins and monitoring builds.

    2. Agent/Slave Nodes 💻:

      • Responsibilities: Agents/slaves are the machines that perform the actual build, test, and deployment operations. They receive tasks from the Master and execute them.

      • Scalability: Multiple agents can be configured to run jobs concurrently, improving scalability and resource utilization.

This distributed architecture makes Jenkins highly scalable and suitable for large-scale CI/CD environments.

3. Features of Jenkins

  • Extensibility with Plugins: Jenkins supports over 1,800 plugins to integrate with various tools, platforms, and technologies like Git, Docker, and Kubernetes. This extensibility makes it adaptable to virtually any development environment.

  • Distributed Builds: Jenkins can distribute builds across multiple agents (slave nodes) to speed up execution and handle larger workloads.

  • Pipeline as Code: Jenkins allows you to define build pipelines using code in a Jenkinsfile, making it easier to version, review, and reuse pipeline definitions.

  • User-Friendly Interface: Jenkins provides a web-based interface that is easy to use, with dashboards to view job statuses, logs, and results.

  • Support for Various Technologies: Jenkins supports building and deploying applications in many languages and environments, including Java, Python, Ruby, .NET, and more.

  • Security Features: Jenkins has built-in security features like role-based access control, user authentication, and encryption for sensitive data like credentials.

4. Pipeline in Jenkins 🛠️

A Jenkins Pipeline is a suite of plugins that supports implementing and integrating continuous delivery pipelines. The pipeline represents your entire workflow, from code commit to deployment, as a series of stages and steps.

  • Declarative vs. Scripted Pipeline:

    • Declarative Pipeline: A simpler and more readable syntax, ideal for most use cases. It's defined within a pipeline block.

    • Scripted Pipeline: Offers more flexibility, written using Groovy syntax, and is preferred when advanced logic is needed.

  • Stages and Steps:

    • Stages: Represent major phases in your pipeline (e.g., Build, Test, Deploy).

    • Steps: Define the actual tasks within each stage, like running scripts, compiling code, or deploying applications.

Example:

    pipeline {
        agent any 
        stages {
            stage('Build') {
                steps {
                    echo 'Building...'
                }
            }
            stage('Test') {
                steps {
                    echo 'Testing...'
                }
            }
            stage('Deploy') {
                steps {
                    echo 'Deploying...'
                }
            }
        }
    }

5. CI/CD Pipeline in Jenkins 🔄

A CI/CD pipeline in Jenkins automates the software development lifecycle, from integrating code changes (CI) to delivering and deploying applications (CD).

  • Continuous Integration (CI): Jenkins monitors the version control system (e.g., Git) for changes in the codebase. When new code is pushed, Jenkins automatically triggers a build, runs tests, and provides feedback to the developers. This helps detect issues early.

  • Continuous Delivery (CD): After a successful build and test cycle, Jenkins can automatically deploy the application to different environments (e.g., staging, production). Continuous Delivery ensures that the application is always ready for deployment.

  • End-to-End Automation: With Jenkins, every step of your development process—from code commit, build, test, and deployment—is automated, reducing manual intervention and speeding up delivery.

CI/CD Pipeline Example:

  • CI: Code is committed -> Jenkins builds the application -> Unit tests run.

  • CD: After tests pass -> Jenkins deploys to a staging environment -> Acceptance tests run -> Deploy to production if all tests pass.

6. Why is Jenkins Useful? 🤔

Jenkins is highly useful for the following reasons:

  • Automates the Software Development Lifecycle: Jenkins enables continuous integration and delivery, automating the entire software development process from code integration to deployment, which helps in reducing manual errors and speeding up the release cycle.

  • Flexibility and Extensibility: Jenkins' extensive plugin ecosystem allows it to integrate with almost any tool in your software development stack, making it highly adaptable to different workflows and environments.

  • Scalability: Jenkins can scale from a single-server setup to a highly distributed system with multiple build agents, which makes it suitable for projects of all sizes.

  • Community and Support: Jenkins has a large and active community that continuously contributes plugins, enhancements, and troubleshooting support, ensuring that it remains up-to-date with the latest technologies.

  • Cost-Effective: Jenkins is open-source and free to use, which makes it an attractive option for teams and organizations looking for a robust CI/CD tool without incurring licensing costs.


These features and capabilities make Jenkins a powerful and versatile tool in modern software development, enabling teams to automate, scale, and streamline their development processes

Conclusion

In conclusion, Jenkins is a powerful, open-source CI/CD automation tool that plays a crucial role in modern DevOps workflows. As highlighted by Deepesh Gupta, its flexibility, extensibility through plugins, and scalable architecture make it ideal for automating software development processes from code integration to deployment. Jenkins' ability to streamline build, test, and deployment tasks helps teams reduce manual errors and speed up release cycles, making it an invaluable tool for projects of all sizes in the DevOps ecosystem.

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