Jenkins 1
Jenkins 1
Jenkins is an open-source automation server primarily used to automate parts of software development like
building, testing, and deploying applications. It supports Continuous Integration (CI) and Continuous
Delivery (CD), helping teams deliver software faster and more reliably.
Uses a structured, predefined syntax with specific blocks (like pipeline, stage, steps).
Easier to read and write, especially for beginners.
Enforces better syntax rules and pipeline structure.
Supports built-in error handling and post actions (post block).
Designed for simple to moderately complex pipelines.
Pipelines are usually stored in a Jenkinsfile in the repo.
Easier to maintain and standardize across teams.
Limited flexibility compared to scripted pipelines but safer.
Uses Groovy-based DSL, but mostly declarative keywords.
Sripted Pipeline
TYPES OF TRIGGERS
Jenkins checks the version control system (like Git) at fixed intervals for changes.
If changes are found, it triggers a build.
Use case: When webhooks are not possible or unreliable.
Triggered instantly when a push or pull request is made to a repository (e.g., GitHub, GitLab).
Requires webhook setup in the repository settings.
Use case: Immediate feedback after code changes.
4.Upstream Trigger
5. Manual Trigger
A developer or user manually starts the job from the Jenkins dashboard or CLI.
Use case: One-time or on-demand builds and deployments.
A webhook in the source code repository sends a signal to Jenkins when a commit happens.
Faster and more efficient than polling.
Use case: Trigger builds instantly on code push (preferred over pollSCM).
WEBHOOK
A webhook is a way for one system (like GitHub or GitLab) to send real-time data to another system (like
Jenkins) when a specific event happens — such as a code push, pull request, or tag creation.
In Jenkins, a webhook triggers a job automatically when an event occurs in the source code repository,
without polling.
How It Works:
When a developer pushes code to a GitHub repository, the webhook notifies Jenkins.
Jenkins automatically runs the pipeline to build, test, and deploy the code.
PARAMETERS
Parameters in Jenkins allow you to pass inputs to a job or pipeline at runtime. They make your pipeline
dynamic and reusable by letting you customize behavior without modifying the Jenkinsfile
Use Cases
1. Environment Selection
o Use Choice Parameter to deploy to dev, QA, or prod.
2. Branch/Tag Input
o Use String or Git Parameter to build a specific branch.
3. Toggle Features
o Use Boolean Parameter to turn on/off debug mode or optional steps.
4. Secure Inputs
o Use Password Parameter for credentials without exposing them in logs.
5. Dynamic Logic
o Use Active Choices to build dynamic UI based on job data or user role.
6. Reusable Jobs
o Use parameters to reuse the same pipeline for multiple services or modules.
JENKINSFILE
A Jenkinsfile is a text file that contains the definition of a Jenkins pipeline, written in either Declarative
or Scripted syntax. It is typically stored in the root of your source code repository
Purpose of a Jenkinsfile:
PLUGINS are modular extensions that add new features or integrations to Jenkins. Jenkins has a plugin-
based architecture, meaning most of its core functionality and external tool support comes from plugins.
Purpose of Plugins:
Use Cases:
LABEL
A label in Jenkins is a tag assigned to nodes (agents/slaves) to identify their capabilities or environment
type. It allows Jenkins to select specific agents to run certain jobs based on their requirements.
Purpose of Labels:
This architecture helps Jenkins scale by distributing build tasks across multiple machines (agents/slaves).
1. Master (Controller)
2. Slave (Agent)
How It Works:
Benefits:
Making Jenkins highly available (HA) means ensuring it keeps running with minimal downtime, even if
some components fail. Here’s how you can achieve Jenkins HA with real-time examples:
Use Multiple Agents: Offload builds to multiple agents so the master isn’t overloaded.
Example: Use Jenkins master on a stable server, with many build agents on separate machines to
distribute workload.
Jenkins by itself doesn’t support active-active master clustering natively, but you can:
Jenkins stores data mainly in the file system, but for large setups, consider using external databases
for specific plugins or metadata (some plugins support it).
6. Real-time Examples
Netflix runs Jenkins with many build agents distributed globally, using Kubernetes for easy scaling
and reliability.
CloudBees Jenkins Enterprise offers official HA solutions with multi-master active-active
architecture.
Open-source setups often use Jenkins on Kubernetes or active-passive failover with shared storage.
Summary Table: