๐Ÿ“˜ Jenkins Summary Guide

๐Ÿ“˜ Jenkins Summary Guide

 

I. What is Jenkins?

Jenkins is an open-source automation server used to automate the building, testing, and deploying of software. It supports Continuous Integration (CI) and Continuous Delivery/Deployment (CD) through a wide range of plugins.


II. Core Concepts

  1. CI/CD

    • Continuous Integration (CI): Automatically integrating code changes into a shared repository.

    • Continuous Delivery (CD): Automatically preparing code for release.

    • Continuous Deployment: Automatically releasing code into production.

  2. Pipeline
    A series of automated steps (like build, test, deploy) defined as code using a Jenkinsfile.

  3. Job / Project
    A runnable task in Jenkins (Freestyle or Pipeline).

  4. Build
    A single execution of a job.


III. Jenkins Architecture

  1. Master (Controller)

    • Manages job scheduling, dispatches builds to agents, stores job config and logs.

    • Provides the UI and REST API.

  2. Agent (Node/Slave)

    • Executes the builds assigned by the master.

    • Can be Linux, Windows, or Docker-based.

  3. Executor

    • A single task runner within a node.

    • A node may have multiple executors (parallel tasks).


IV. Jenkinsfile (Pipeline as Code)

A Jenkinsfile is a text file that contains the definition of a Jenkins Pipeline and is typically stored in a Git repository.

Two Pipeline Syntax Types:

  1. Declarative Pipeline (Recommended)
    Easier to read and write. Example:

    groovy

    pipeline { agent any stages { stage('Build') { steps { echo 'Building...' } } stage('Test') { steps { echo 'Testing...' } } stage('Deploy') { steps { echo 'Deploying...' } } } }
  2. Scripted Pipeline
    Uses full Groovy scripting and offers more flexibility.



V. Jenkins Job Types

  1. Freestyle Project
    Simple job with GUI-based configuration.

  2. Pipeline Project
    Defined via Jenkinsfile; supports complex workflows and stages.

  3. Multibranch Pipeline
    Automatically creates pipelines for each branch in a Git repository.

  4. Folder
    Organizes jobs and configurations hierarchically.


VI. Plugins

Jenkins is highly extensible through plugins. Common types:

  • SCM Plugins: Git, GitHub, Bitbucket

  • Build Tools: Maven, Gradle, Ant

  • Notifiers: Slack, Email

  • Container Tools: Docker, Kubernetes

  • Test Reports: JUnit, Allure


VII. Important Jenkins Concepts

ConceptDescription
AgentMachine that runs builds.
WorkspaceDirectory where Jenkins builds code.
ArtifactsFiles generated by a build (e.g., .jar, .war).
SCM (Source Control Management)Integrates Git, SVN, etc.
ParametersUser input or variables for builds.
TriggersStart jobs automatically (e.g., on Git push, schedule).
Post-actionsSteps that run after stages (e.g., always, success, failure).

VIII. Security in Jenkins

  1. Users & Roles
    Manage via Matrix Authorization Strategy or Role-Based Plugin.

  2. Authentication
    Integrates with LDAP, Active Directory, GitHub, etc.

  3. Credentials
    Stores secrets like passwords, tokens, and SSH keys.


IX. Jenkins Deployment Options

  • Standalone WAR file: java -jar jenkins.war

  • As a System Service (e.g., via Linux package manager)

  • In a Container (Docker)

  • In the Cloud (e.g., Jenkins on Kubernetes or AWS)


X. Best Practices

  1. Use Pipelines as Code (Jenkinsfile).

  2. Keep master lightweight; offload builds to agents.

  3. Use shared libraries for common functions.

  4. Secure credentials using Jenkins Credentials Manager.

  5. Use folders and multibranch pipelines for large repos.

  6. Archive artifacts and store test reports.

  7. Monitor with plugins like Prometheus, Audit Trail.



Comments

Popular posts from this blog

SAVE TAX ๐Ÿ’ต

LIFE A JOURNEY

๐ŸฆŸ The Truth About Mosquitoes: More Than Just an Itchy Bite