New batchZero to DevOps starts 29 Nov · limited seatsReserve your seat
Cheat sheetsJenkinsJenkins
FreeSheet 01 of 7

Jenkins Basics & Installation

A comprehensive developer cheatsheet covering Jenkins fundamentals and installation, featuring essential CLI commands, master-agent architecture, initial setup workflows, and UI navigation.

What is Jenkins?

Jenkins is an open-source automation server used for building, testing, and deploying software. It is the most popular CI/CD (Continuous Integration / Continuous Delivery) tool.

Key Features

FeatureDescription
CI/CD PipelineAutomate build, test, and deploy
Plugin Ecosystem1000+ plugins for integration
Distributed BuildsMaster-agent architecture
Declarative & Scripted PipelinesCode your CI/CD as code
ExtensibleCustom plugins and integrations

Jenkins Use Cases

  • Automate build processes
  • Run automated tests (unit, integration, acceptance)
  • Deploy applications to staging/production
  • Monitor build health and test results
  • Trigger workflows based on code changes

Jenkins Architecture

Master-Agent Architecture

ComponentDescription
Jenkins MasterCentral controller, schedules jobs, stores configuration
Jenkins AgentsRun build jobs, execute tasks
Build ExecutorsThreads that run jobs on agents

Components

text
┌─────────────────────────────────────────────────────────────┐
│                     Jenkins Master                          │
│  ┌─────────────────────────────────────────────────────┐    │
│  │  Job Scheduler  │  Plugin Manager  │  UI Server    │    │
│  └─────────────────────────────────────────────────────┘    │
│  ┌─────────────────────────────────────────────────────┐    │
│  │                Build Queue                          │    │
│  └─────────────────────────────────────────────────────┘    │
└─────────────────────────────────────────────────────────────┘
                              │
              ┌───────────────┼───────────────┐
              ▼               ▼               ▼
      ┌───────────┐   ┌───────────┐   ┌───────────┐
      │  Agent 1  │   │  Agent 2  │   │  Agent 3  │
      │  Linux    │   │  Windows  │   │  macOS    │
      └───────────┘   └───────────┘   └───────────┘

Jenkins Installation

Installation Methods

MethodUse CaseCommand
DockerQuick start, dev/testdocker run -p 8080:8080 jenkins/jenkins:lts
WAR FileCustom Java setupjava -jar jenkins.war
Linux PackageProduction on Linuxsudo apt install jenkins
Windows InstallerProduction on WindowsDownload .msi installer
KubernetesCloud-nativeHelm charts

Docker Installation (Quick Start)

bash
# Pull and run Jenkins (LTS version)
$ docker run -p 8080:8080 -p 50000:50000 -v jenkins_home:/var/jenkins_home jenkins/jenkins:lts

# With volume for persistence
$ docker run -d \
  --name jenkins \
  -p 8080:8080 \
  -p 50000:50000 \
  -v jenkins_home:/var/jenkins_home \
  jenkins/jenkins:lts

# View initial admin password
$ docker logs jenkins

Linux (Ubuntu/Debian) Installation

bash
# Add Jenkins repository
$ curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee /usr/share/keyrings/jenkins-keyring.asc > /dev/null
$ echo "deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian-stable binary/" | sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/null

# Install Jenkins
$ sudo apt update
$ sudo apt install jenkins -y

# Start Jenkins
$ sudo systemctl start jenkins
$ sudo systemctl enable jenkins

# Check status
$ sudo systemctl status jenkins

Initial Setup

Step 1: Get Initial Admin Password

bash
# Linux
$ sudo cat /var/lib/jenkins/secrets/initialAdminPassword
abc123def456...

# Docker
$ docker logs jenkins

Step 2: Access Jenkins Web UI

Open browser: http://localhost:8080

Step 3: Install Suggested Plugins

Click "Install suggested plugins" on the setup page.

Step 4: Create Admin User

Create the first admin user account.

Step 5: Set Jenkins URL

Set the Jenkins URL (default: http://localhost:8080).


Jenkins CLI Basics

Jenkins CLI Commands

CommandPurposeExample
helpShow helpjava -jar jenkins-cli.jar help
versionShow versionjava -jar jenkins-cli.jar version
list-jobsList all jobsjava -jar jenkins-cli.jar list-jobs
buildBuild a jobjava -jar jenkins-cli.jar build my-job
disable-jobDisable jobjava -jar jenkins-cli.jar disable-job my-job
enable-jobEnable jobjava -jar jenkins-cli.jar enable-job my-job
delete-jobDelete jobjava -jar jenkins-cli.jar delete-job my-job
get-jobGet job XMLjava -jar jenkins-cli.jar get-job my-job > job.xml
create-jobCreate job from XMLcat job.xml | java -jar jenkins-cli.jar create-job my-job
update-jobUpdate job from XMLcat job.xml | java -jar jenkins-cli.jar update-job my-job
reload-configurationReload configjava -jar jenkins-cli.jar reload-configuration

Using Jenkins CLI

Download Jenkins CLI:

bash
$ wget http://localhost:8080/jnlpJars/jenkins-cli.jar

Run CLI Commands:

bash
# With username/password
$ java -jar jenkins-cli.jar -s http://localhost:8080 -auth admin:password list-jobs

# With SSH (if enabled)
$ ssh -l admin localhost -p 2222 help

Jenkins CLI Examples

List all jobs:

bash
$ java -jar jenkins-cli.jar -s http://localhost:8080 list-jobs
my-app-build
my-app-test
my-app-deploy

Build a job:

bash
$ java -jar jenkins-cli.jar -s http://localhost:8080 build my-app-build

Build with parameters:

bash
$ java -jar jenkins-cli.jar -s http://localhost:8080 build my-app-build -p BRANCH=develop

Get job XML:

bash
$ java -jar jenkins-cli.jar -s http://localhost:8080 get-job my-app-build > my-app-build.xml

Create job from XML:

bash
$ cat my-app-build.xml | java -jar jenkins-cli.jar -s http://localhost:8080 create-job my-app-build

Reload configuration:

bash
$ java -jar jenkins-cli.jar -s http://localhost:8080 reload-configuration

Jenkins Web UI Overview

Key Sections

SectionDescription
DashboardHome page with job list
New ItemCreate a new job or pipeline
Manage JenkinsSystem configuration, plugins, security
Build QueuePending builds
Build Executor StatusRunning builds
My ViewsCustom dashboards
CredentialsManage API keys, passwords, tokens

Dashboard View

text
┌─────────────────────────────────────────────────────────────┐
│  Jenkins Dashboard                                          │
│  ┌─────────────────────────────────────────────────────┐    │
│  │  New Item  │  Manage Jenkins  │  Credentials       │    │
│  └─────────────────────────────────────────────────────┘    │
│  ┌─────────────────────────────────────────────────────┐    │
│  │  Build Queue                    │  Build Executor  │    │
│  │  (0 builds pending)             │  (2 executors)   │    │
│  └─────────────────────────────────────────────────────┘    │
│  ┌─────────────────────────────────────────────────────┐    │
│  │  Jobs                                               │    │
│  │  ├── my-app-build          │  (SVG) │  (Last: 5m) │    │
│  │  ├── my-app-test           │  (SVG) │  (Last: 10m)│    │
│  │  └── my-app-deploy         │  (SVG) │  (Last: 1h) │    │
│  └─────────────────────────────────────────────────────┘    │
└─────────────────────────────────────────────────────────────┘

Manage Jenkins Sections

SectionDescription
System ConfigurationJenkins URL, global properties
PluginsManage plugins
ToolsJDK, Maven, Git, Gradle
NodesManage agents
CredentialsManage credentials
SecuritySecurity settings
System LogJenkins logs
Script ConsoleGroovy scripts

Quick Reference — Most Used Commands

TaskCommand
Start Jenkins (Docker)docker run -p 8080:8080 jenkins/jenkins:lts
Start Jenkins (Linux)sudo systemctl start jenkins
View initial passwordsudo cat /var/lib/jenkins/secrets/initialAdminPassword
List jobsjava -jar jenkins-cli.jar list-jobs
Build jobjava -jar jenkins-cli.jar build my-job
Build with paramsjava -jar jenkins-cli.jar build my-job -p BRANCH=develop
Get job XMLjava -jar jenkins-cli.jar get-job my-job > job.xml
Create job from XMLcat job.xml | java -jar jenkins-cli.jar create-job my-job
Reload configjava -jar jenkins-cli.jar reload-configuration
Restart Jenkinssudo systemctl restart jenkins

Pro Tips

  1. Initial Admin Password — saved in /var/lib/jenkins/secrets/initialAdminPassword (Linux) or jenkins_home directory.

  2. Jenkins Home Directory — contains all job configurations, plugins, build history.

  3. Backup Jenkins Home — for disaster recovery.

  4. Use LTS Version — Long-Term Support is more stable for production.

  5. Memory Requirements — Jenkins needs at least 256MB RAM (1GB+ recommended).

  6. Docker Persistence — mount a volume for jenkins_home to persist data.

  7. Plugins — install only what you need to keep Jenkins fast.

  8. Disable Demo/Example Jobs — remove them after setup.


Next in JenkinsJob Types & Freestyle Jobs