Note_Tech

All technological notes.


Project maintained by simonangel-fong Hosted on GitHub Pages — Theme by mattgraham

Jenkins - Fundamental

Back


Fundamental


Items

Items Description
Pipeline A continuous delivery pipeline, which is configured via a Jenkinsfile (Pipeline as Code).
Freestyle Project General-purpose job type.
Folder A container that stores nested items
Multibranch Pipeline managing CI/CD pipelines for multiple branches in one version control repository.
Organization Folders Creates a set of multibranch project subfolders by scanning for repositories.

Build

Jenkins build lifecycle:

  1. Triggering a Build:
    • Initiating the build process through manual, scheduled, or event-driven triggers.
  2. Initialization:
    • Setting up the build environment and resources.
  3. Source Code Checkout:
    • Getting the latest code from version control.
  4. Build Process:
    • Executing build scripts, compiling code, and performing necessary tasks.
  5. Testing:
    • Running test suites and reporting results.
  6. Deployment:
    • Releasing built artifacts to target environments.
  7. Post-Build Actions:
    • Archiving artifacts, publishing reports, and sending notifications.
  8. Recording and Reporting:
    • Collecting and storing build data and results.
  9. Clean-Up:
    • Managing resources and resetting the environment.

Architecture

        +----------------------+
        |     Jenkins UI       |
        |  (Web Interface/API) |
        +----------+-----------+
                   |
                   v
        +----------------------+
        |   Jenkins Controller |
        |  (Master Node)       |
        +----------+-----------+
                   |
        ----------------------------
        |            |            |
        v            v            v
+-------------+ +-------------+ +-------------+
|   Agent 1   | |   Agent 2   | |   Agent N   |
| (Worker)    | | (Worker)    | | (Worker)    |
+-------------+ +-------------+ +-------------+

Core Components

Jenkins Controller (Master)



Jenkins Agents (Workers)



How It Works (Execution Flow)

  1. Developer pushes code to GitHub
  2. Jenkins detects change (webhook or polling)
  3. Job is triggered and placed in queue
  4. Controller selects an available agent
  5. Agent executes pipeline steps
  6. Results are sent back to controller
  7. Output shown in Jenkins UI

Common Deployment Patterns

  1. Single Node (Small Setup) Controller + executor on same machine Simple but not scalable
  2. Controller + Multiple Agents (Recommended) Production-ready setup
  3. Cloud-Native Jenkins Controller in VM/container Agents dynamically provisioned (Kubernetes)

Plugins


Common Configurations

Environment Variables

pipeline {
    agent {
        label '!windows'
    }

    environment {
        DISABLE_AUTH = 'true'
        DB_ENGINE    = 'sqlite'
    }

    stages {
        stage('Build') {
            steps {
                echo "Database engine is ${DB_ENGINE}"
                echo "DISABLE_AUTH is ${DISABLE_AUTH}"
                sh 'printenv'
            }
        }
    }
}

Jenkins URL


Notification


Common Practices

Blue-Green deployment strategy


Backup