devops

02 - Architecture, Setup, & Projects


After grasping the core theory of CI/CD, the next step is installing Jenkins and launching projects.

Jenkins Architecture

Jenkins is designed using a distributed architecture to handle heavy CI/CD workloads efficiently:

  • Jenkins Controller (Master): The central brain. It handles the web UI, schedules build jobs, dispatches builds, and monitors agents. It should not run heavy workloads.
  • Nodes/Agents (Slaves): Dedicated worker machines (Linux, Windows, Docker containers) that execute the actual heavy lifting (building, testing, deploying).

Understanding Jenkins Controller and Nodes

Naming You Will See

TermMeaning
AgentCurrent Jenkins term for a worker that runs builds.
NodeAny machine entry in Jenkins (controller + agents).
ExecutorOne concurrent build slot on a node (you can set several per agent).
LabelTag used in pipelines (agent { label 'docker' }) to pick agents.
SlaveDeprecated old name for agent — avoid in new docs.

Installation Methods

Hardware and Software Prerequisites

Jenkins is a Java application and operates identically regardless of how it’s installed. Common options include:

  1. Linux Native Package (APT/YUM): Installs Jenkins as a native systemd service.
  2. WAR File: Direct Java execution (java -jar jenkins.war).
  3. Docker: Highly recommended. Running Jenkins as a container keeps your host system clean. docker run -p 8080:8080 jenkins/jenkins:lts gives you an instant CI/CD server.

Project Types in Jenkins

Jenkins Default Project Types

The core unit of work in Jenkins is called a Job or Project.

  • Freestyle Project: The classic approach. You configure source code retrieval, build steps, and post-build actions strictly through the Jenkins web GUI.
  • Pipeline: Modern Jenkins. You write your build logic in a Jenkinsfile (code) and store it with your source code.
  • Multibranch Pipeline: Automatically detects branches in Git and spins up dynamic CI/CD pipelines for each branch.

Jenkins New Item Interface

Freestyle Projects: Chaining & Limitations

Freestyle projects execute shell commands sequentially. If you attempt a multi-stage deployment (Build -> Test -> Deploy) inside a single Freestyle job, a single script failure crashes the entire process and tangles your code logic.

Instead, you can split them and chain them using Post-Build Actions (e.g., “Build other projects”):

  1. ASCII-Build-Job finishes -> Triggers ASCII-Test-Job
  2. ASCII-Test-Job finishes -> Triggers ASCII-Deploy-Job

Configuring Post Build Actions

The Workspace Isolation Problem

When chaining Freestyle jobs to form pipelines, you encounter a strict architectural rule: Workspace Isolation.

The Build job saves its files in its own isolated directory. When the Test job starts, it cannot see the files the Build job generated. It receives a fresh, blank workspace.

Jenkins File Missing Error

Solution: To pass files between separate Freestyle Jobs, you must archive and share them explicitly using the Copy Artifact Plugin, or completely upgrade to using modern Jenkins Pipelines.

Quick Ops Commands

Terminal window
# Service (typical Linux package install)
sudo systemctl status jenkins
sudo systemctl restart jenkins
# Logs
sudo journalctl -u jenkins -f