Jenkins (CI/CD)
Concepts
From Concepts
Go to text →
Concepts Visualization
General Concepts mapping
graph LR;
A[Jenkins] -->|Defines| B[Pipeline];
A -->|Manages| C[Jobs];
A -->|Distributes Work| D[Nodes & Agents];
B -->|Defined in| F[Jenkinsfile];
B -->|Executes| G[Stages & Steps];
H[SCM ex:Git];
B -->|Produces| I[Artifacts];
B -->|Triggered by| J[Triggers];
C -->|Executed on| D;
C -->|Uses| H;
C -->|Generates| K[Builds];
C -->|Stores| L[Workspace];
D -->|Has| M[Executors];
D -->|Runs| K;
K -->|Generates| N[Logs & Console Output];
K -->|Stores| I;
K -->|Executes| O[Post-build Actions];
H -->|Triggers| J;
J -->|Can be| P[Webhook & Polling & Manual];
R[Blue Ocean] -->|Visualizes| B;
S[Credentials] -->|Used in| C;
S -->|Securely Stores| T[Passwords & API Keys];
U[Environment Variables] -->|Used in| C;
Using Jenkins with Code Defined Pipelines
flowchart TB
%% Main Focus
A["Using Jenkins with Code Defined Pipelines"] -->|Operates in| B["Jenkins Environment"]
A -->|Realized as| C["Code Defined Pipeline"]
%% Jenkins Environment branch
B -->|Manages| D["Jobs & Builds"]
B -->|Distributes work via| E["Nodes & Agents"]
B -->|Enhances functionality with| F["Plugins"]
%% Code Defined Pipeline branch
C -->|Expressed through| G["Pipeline as Code"]
C -->|Configured with| H["Jenkinsfile"]
C -->|Integrates with| I["SCM (e.g., Git, SVN)"]
C -->|Initiated by| J["Triggers (Webhook, Polling, Manual)"]
C -->|Produces| K["Artifacts & Logs"]
%% Additional relationships and details
H -->|Is stored in| I
K -->|Leads to| L["Post-build Actions"]
%% Cross-link: Plugins support pipeline capabilities
F ---|Supports| G
Concepts list
1. Pipeline
- A series of automated steps that define how a project is built, tested, and deployed.
- Can be defined using a Jenkinsfile written in Groovy-based DSL.
- Supports both Declarative and Scripted pipeline syntaxes.
2. Job (Project)
- Represents a unit of work in Jenkins.
- Can be a Freestyle Job (configured via UI) or a Pipeline Job (defined via a Jenkinsfile).
- Types of jobs include:
- Freestyle Project
- Pipeline
- Multibranch Pipeline
- Folder (for grouping jobs)
- External Job (to track work done outside Jenkins)
3. Node (Agent)
- A machine (physical or virtual) that runs build tasks.
- Master-Agent Architecture allows distributing workload across multiple nodes.
- Controller (formerly Master): Coordinates jobs and assigns work to agents.
- Agent (formerly Slave): Executes jobs as per the controller’s instructions.
4. Executor
- A thread that runs on an agent to execute a job.
- Each agent has a configurable number of executors.
5. Workspace
- A directory where Jenkins checks out code, builds, and tests applications.
- Each job has a separate workspace on the assigned agent.
6. Build
- A single execution of a job.
- Each build has a unique build number and stores logs, artifacts, and results.
7. SCM (Source Code Management)
- Jenkins integrates with Git, SVN, Mercurial, etc.
- Can automatically trigger jobs when new changes are detected in the repository.
8. Triggers
- Define when a job should start, such as:
- Webhook Triggers (e.g., GitHub, GitLab)
- Polling SCM (Jenkins periodically checks for changes)
- Scheduled Jobs (Cron-like syntax)
- Manual Triggering
9. Artifacts
- Output files generated by a build (e.g., JAR, WAR, logs, reports).
- Can be stored in Jenkins or external artifact repositories (Nexus, Artifactory).
10. Plugins
- Extend Jenkins functionality (e.g., Slack notifications, SonarQube, Docker, Kubernetes).
- Jenkins has a vast Plugin Ecosystem for CI/CD integration.
11. Credentials
- Securely store passwords, API tokens, SSH keys, etc.
- Used in jobs to interact with external services.
12. Environment Variables
- Provide dynamic values in jobs (e.g.,
BUILD_NUMBER
,WORKSPACE
,GIT_COMMIT
).
13. Post-build Actions
- Steps executed after a build completes, such as:
- Sending notifications
- Deploying artifacts
- Triggering other jobs
14. Jenkinsfile
- Defines a pipeline as code.
- Stored in the project’s SCM repository.
- Enables Infrastructure as Code (IaC) for build automation.
15. Multibranch Pipeline
- Automatically creates and runs pipelines for each branch in a repository.
- Useful for Git workflows like feature branches.
16. Blue Ocean
- A modern UI for Jenkins pipelines.
- Provides a visual representation of pipelines.
17. Logs & Console Output
- Build logs are accessible from the Jenkins UI.
- Useful for debugging failed builds.
Children