JENKINS
MASTERY

// Automate everything.

MANUAL BUILDS ARE FOR AMATEURS.

Jenkins automates your software delivery pipeline. Every commit can trigger builds, tests, and deployments. Ship faster with confidence.

CI/CD IS NOT OPTIONAL.

In modern software development, continuous integration and delivery are essential. Jenkins is the open-source standard that powers thousands of deployments worldwide.

BEGIN YOUR JOURNEY

// Your Training Path

Click a lesson to begin

LESSON 01

Introduction to Jenkins

What is CI/CD? Jenkins overview and installation.

Beginner
LESSON 02

First Job

Create your first Jenkins job. Build a simple project.

Beginner
LESSON 03

Source Control Integration

Trigger builds from Git commits. Webhooks.

Beginner
LESSON 04

Build Triggers

Poll SCM, timers, upstream jobs, and webhooks.

Beginner
LESSON 05

Pipelines

Jenkinsfile, scripted vs declarative pipelines.

Intermediate
LESSON 06

Automated Testing

Run tests in pipeline. Test reporting.

Intermediate
LESSON 07

Artifacts

Store build outputs. Archive artifacts.

Intermediate
LESSON 08

Parameters

Parameterized builds. User inputs.

Intermediate
LESSON 09

Distributed Builds

Agents, nodes, and distributed execution.

Advanced
LESSON 10

Security

User management, credentials, and permissions.

Advanced
LESSON 11

Plugins

Extend Jenkins. Popular plugins.

Advanced
LESSON 12

Best Practices

Pipeline patterns, scalability, and maintenance.

Advanced

// Lesson 01: Introduction to Jenkins

×

What is Jenkins?

Jenkins is an open-source automation server for CI/CD. It automates building, testing, and deploying software.

Key Concepts

  • Job: A task or workflow
  • Build: An execution of a job
  • Pipeline: A workflow defined as code
  • Agent: A machine that runs builds

Installing Jenkins

# Install Java
sudo apt update
sudo apt install openjdk-11-jdk

# Add Jenkins repo
wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo tee /etc/apt/trusted.gpg.d/jenkins.asc
echo "deb https://pkg.jenkins.io/debian binary/" | sudo tee /etc/apt/sources.list.d/jenkins.list
sudo apt update
sudo apt install jenkins

# Start Jenkins
sudo systemctl start jenkins
sudo systemctl enable jenkins

First Access

Navigate to http://localhost:8080 and use the initial admin password.

Quiz

1. What is Jenkins used for?

Show Answers
  1. CI/CD / automation

// Lesson 02: First Job

×

Creating Your First Job

  1. Click "New Item"
  2. Enter job name
  3. Select "Freestyle project"
  4. Configure build steps
  5. Click "Save"

Build Steps

  • Execute shell: Run commands
  • Execute Windows batch: Run Windows commands
  • Invoke Ant: Run Ant builds
  • Invoke Gradle: Run Gradle builds

Example: Hello World

# Build step - Execute shell
echo "Hello from Jenkins!"
date
whoami

Quiz

1. What type of project is simplest?

Show Answers
  1. Freestyle project

// Lesson 03: Source Control Integration

×

Connecting to Git

  1. Edit your job
  2. Go to "Source Code Management"
  3. Select "Git"
  4. Enter repository URL
  5. Specify branches

Repository URL Examples

# Public repo
https://github.com/user/repo.git

# Private repo (with credentials)
git@github.com:user/repo.git

# Specific branch
*/main
*/develop

Credentials

  • Click "Add" in Credentials
  • Select "Username with password"
  • Enter GitHub username/token
  • Use credentials in job

Quiz

1. Where do you configure Git in a job?

Show Answers
  1. Source Code Management section

// Lesson 04: Build Triggers

×

Trigger Types

Poll SCM

Check for changes at intervals:

# Check every 5 minutes
H/5 * * * *

# Check every 15 minutes
H/15 * * * *

Build Periodically

Schedule builds at specific times:

# Every day at midnight
0 0 * * *

# Every Monday at 6am
0 6 * * 1

Trigger from GitHub

  • Install GitHub plugin
  • Enable "GitHub hook trigger for GITScm polling"
  • Add webhook in GitHub settings

Quiz

1. How often does H/5 * * * * check?

Show Answers
  1. Every 5 minutes

// Lesson 05: Pipelines

×

What is a Pipeline?

A pipeline is a workflow defined as code. It's versioned, reviewed, and more powerful than freestyle jobs.

Declarative Pipeline

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

Scripted Pipeline

node {
    stage('Build') {
        echo 'Building...'
    }
    stage('Test') {
        echo 'Testing...'
    }
    stage('Deploy') {
        echo 'Deploying...'
    }
}

Jenkinsfile

Store your pipeline in a Jenkinsfile in your repository.

Quiz

1. What file stores pipeline as code?

Show Answers
  1. Jenkinsfile

// Lesson 06: Automated Testing

×

Running Tests in Pipeline

pipeline {
    agent any
    stages {
        stage('Test') {
            steps {
                sh 'npm test'
            }
            post {
                always {
                    junit 'reports/*.xml'
                }
            }
        }
    }
}

Test Reports

  • JUnit: Java tests
  • Cobertura: Code coverage
  • HTML Publisher: Custom reports

Test Results in Pipeline

post {
    always {
        junit 'test-results/*.xml'
    }
    success {
        echo 'Tests passed!'
    }
    failure {
        echo 'Tests failed!'
    }
}

Quiz

1. What publishes JUnit test results?

Show Answers
  1. junit step

// Lesson 07: Artifacts

×

What are Artifacts?

Artifacts are build outputs that are preserved after the build completes.

Archive Artifacts

pipeline {
    agent any
    stages {
        stage('Build') {
            steps {
                sh 'make'
            }
        }
    }
    post {
        always {
            archiveArtifacts artifacts: 'build/**/*', fingerprint: true
        }
    }
}

Stash and Unstash

Transfer files between stages or agents:

stage('Build') {
    steps {
        stash name: 'my-artifacts', includes: 'dist/**'
    }
}

stage('Deploy') {
    steps {
        unstash 'my-artifacts'
    }
}

Quiz

1. What step saves files between stages?

Show Answers
  1. stash / unstash

// Lesson 08: Parameters

×

Parameterized Builds

Let users provide input when triggering builds.

Parameter Types

  • String: Text input
  • Choice: Dropdown
  • Boolean: Checkbox
  • Password: Secret input
  • File: File upload

Example: Choice Parameter

parameters {
    choice(name: 'ENV', choices: ['dev', 'staging', 'prod'], description: 'Deploy environment')
    string(name: 'VERSION', defaultValue: '1.0.0', description: 'Version to deploy')
    booleanParam(name: 'SKIP_TESTS', defaultValue: false, description: 'Skip tests?')
}

Using Parameters

steps {
    sh "./deploy.sh -e ${params.ENV} -v ${params.VERSION}"
}

Quiz

1. What parameter creates a dropdown?

Show Answers
  1. choice

// Lesson 09: Distributed Builds

×

Jenkins Agents

Scale your builds by adding more machines.

Agent Types

  • Permanent: Always online
  • JNLP: Connect via JNLP protocol
  • SSH: Connect via SSH
  • Cloud: Dynamic agents (Kubernetes, AWS)

Adding an Agent via SSH

  1. Manage Jenkins → Manage Nodes
  2. New Node
  3. Enter name, select "Permanent Agent"
  4. Configure SSH connection
  5. Add credentials

Distribute Builds

pipeline {
    agent none
    
    stages {
        stage('Build on Linux') {
            agent { label 'linux' }
            steps {
                echo 'Building on Linux'
            }
        }
        stage('Build on Windows') {
            agent { label 'windows' }
            steps {
                echo 'Building on Windows'
            }
        }
    }
}

Quiz

1. What runs builds on other machines?

Show Answers
  1. Agents / nodes

// Lesson 10: Security

×

User Management

Matrix Authorization

  • Overall: Administer, Read
  • Job: Build, Configure, Delete
  • Run: Update
  • View: Configure

Credentials

  • Manage Jenkins → Manage Credentials
  • Add username/password
  • Add SSH credentials
  • Add secrets (API keys, tokens)

Secure Pipeline

pipeline {
    options {
        buildDiscarder(logRotator(numToKeepStr: '30'))
        timeout(time: 1, unit: 'HOURS')
    }
    stages {
        // your stages
    }
}

Quiz

1. Where are API keys stored?

Show Answers
  1. Credentials

// Lesson 11: Plugins

×

Extending Jenkins

Plugins add functionality to Jenkins.

Essential Plugins

  • Pipeline: Pipeline as code
  • Git: Git integration
  • GitHub: GitHub integration
  • Docker: Docker integration
  • Blue Ocean: Modern UI
  • Credentials: Secret management

Installing Plugins

  1. Manage Jenkins → Manage Plugins
  2. Available tab
  3. Search and install
  4. Restart Jenkins

Popular Plugin Pipelines

// Kubernetes
podTemplate(...) {
    node {
        stage('Build') {
            container('builder') {
                sh 'make'
            }
        }
    }
}

Quiz

1. What adds Docker support?

Show Answers
  1. Docker plugin

// Lesson 12: Best Practices

×

Pipeline Best Practices

  • Jenkinsfile: Store pipeline in version control
  • One stage per job: Keep pipelines focused
  • Fail fast: Fail early in the pipeline
  • Clean up: Archive artifacts, clean workspace

Scalability

  • Use agents, not master
  • Shared libraries for common code
  • Cloud agents for burst capacity
  • Pipeline templates

Maintenance

  • Clean up old builds
  • Update plugins regularly
  • Backup configuration
  • Monitor disk space

Congratulations!

You've completed the Jenkins Mastery guide. You now understand:

  • Jenkins fundamentals
  • Creating jobs
  • Git integration
  • Build triggers
  • Pipelines
  • Automated testing
  • Artifacts
  • Parameters
  • Distributed builds
  • Security
  • Plugins
  • Best practices

// Why Jenkins

Jenkins is the most popular open-source automation server. It powers CI/CD at thousands of companies worldwide.

Whether you're a solo developer or part of a large team, Jenkins helps you ship faster with confidence.

Automate everything. Ship faster.

// Tools & References

Jenkins Documentation

Official Docs

jenkins.io

Pipeline Guide

Pipeline as Code

jenkins.io/pipeline

Blue Ocean

Modern UI

jenkins.io/blueocean

Plugin Index

Jenkins Plugins

plugins.jenkins.io

Jenkins.io

Official Website

jenkins.io

Shared Libraries

Reusable Pipeline Code

jenkins.io