Imagine you are working on a Spring Boot project with a team of five developers.
Every developer writes code, pushes changes to GitHub, and creates pull requests.
Now, whenever someone pushes new code, your team needs to:
- Download the latest source code.
- Compile the application.
- Run unit tests.
- Check code quality.
- Package the application into a JAR file.
- Build a Docker image.
- Deploy the application.
What if someone forgets to run the tests? What if the application works on one developer's machine but fails on the server?
And what if you need to repeat these operations every time someone pushes new code?
Doing everything manually is repetitive and error-prone.
Wouldn't it be better to automate this entire process?
This is where Jenkins comes into the picture.
Jenkins is a free and open-source automation server that helps automate software building, testing, and delivery or deployment.
Instead of manually performing every operation, we can configure Jenkins to execute these tasks automatically whenever new code is pushed to GitHub.
In this article, we'll understand what Jenkins is, why we need it, how CI/CD works, what a Jenkins Pipeline is, and how Jenkins integrates with tools like Maven, SonarQube, Docker, and Kubernetes.
We'll also create a simple Jenkins Pipeline using a Jenkinsfile.
Versions used in this article:
- Jenkins LTS: 2.580.3.
- Java for running Jenkins: JDK 21 or JDK 25.
- Maven: Examples use standard Maven commands.
- Jenkins Pipeline: Declarative Pipeline syntax.
Jenkins 2.580.3 was released on November 25, 2026. The Jenkins runtime requirements and compatible Java versions are discussed later in the article.
Table of contents
- What is Jenkins?
- The problem Jenkins solves
- What CI and CD mean
- Understanding Jenkins architecture
- Jenkins controller and agents
- Why Jenkins uses plugins
- From source code to deployment
- What each tool does
- What is a Jenkins Pipeline?
- Job vs pipeline
- Stages and steps
- Declarative vs Scripted Pipeline
- Create your first Jenkins Pipeline
- A minimal Jenkinsfile
- Connect Jenkins to GitHub
- Build with Maven and analyze with SonarQube
- What Maven and SonarQube do
- A practical Jenkinsfile
- How the pipeline executes
- Docker and Kubernetes
- Which one should I use?
- Common mistakes
- Quick recap
- Try it yourself
What is Jenkins?
Jenkins is a free and open-source automation server used to automate software development tasks.
These tasks include:
- Building applications.
- Running tests.
- Checking code quality.
- Packaging applications.
- Deploying applications.
- Executing repetitive development and operational tasks.
In simple words, Jenkins takes tasks that developers or operations teams normally perform manually and executes them automatically based on predefined instructions.
For example:
Developer writes code | v Developer pushes code to GitHub | v Jenkins detects new changes | v Jenkins starts a build | v Runs tests | v Builds application | v Deploys application Once configured, this entire process can happen automatically.
Jenkins is also extensible.
It supports plugins that allow it to integrate with different development and deployment tools.
For example:
- Git and GitHub for source code management.
- Maven and Gradle for building applications.
- SonarQube for code quality analysis.
- Docker for building container images.
- Kubernetes for container orchestration.
One important thing to understand:
Jenkins does not replace these tools. It coordinates them.
For example, Maven is still responsible for building a Java application. Jenkins simply triggers Maven at the appropriate stage of the automation process.
The problem Jenkins solves
Let's imagine a developer named Asha working on a Spring Boot application.
Every time Asha pushes code, the team wants to perform the following operations:
- Get the latest code.
- Compile the Java source code.
- Run unit tests.
- Check code quality.
- Generate a JAR file.
- Deploy the application.
Without Jenkins, someone might have to perform these operations manually.
WITHOUT JENKINS Developer | v GitHub Push | v Manual Checkout | v Manual Build | v Manual Testing | v Manual Review | v Manual Packaging | v Deployment This process is repetitive and depends heavily on human involvement.
Now introduce Jenkins.
WITH JENKINS Developer | v GitHub Push | v Jenkins | +------+------+ | | | v v v Build Test Quality | v Package | v Deploy Once configured, Jenkins automatically executes the required stages.
If a build or test fails, the pipeline can stop instead of continuing with an invalid application.
This is the main problem Jenkins solves: automating and coordinating repetitive software development and delivery tasks.
What CI and CD mean
You will frequently hear Jenkins being associated with CI/CD.
Let's understand these terms.
CI stands for Continuous Integration.
Continuous Integration is a development practice where developers frequently integrate their code changes into a shared repository.
Whenever code changes are integrated, an automated process can:
- Build the application.
- Run unit tests.
- Check code quality.
- Report failures.
The goal is to identify problems early rather than discovering them after several weeks of development.
For example:
Developer A ----+ | Developer B ----+----> GitHub | Developer C ----+ | v Jenkins | Build and Tests | Success / Failure Instead of waiting until the end of development, we verify changes continuously.
CD stands for Continuous Delivery or Continuous Deployment.
These are related but slightly different practices.
Continuous Delivery
The application is automatically built, tested, and prepared for release.
However, deploying to production may still require manual approval.
For example:
Code | v Build | v Test | v Package | v Deploy to Staging | v Manual Approval | v Production Release Continuous Deployment
In continuous deployment, every change that successfully passes the required checks is automatically released to production.
Code | v Build | v Test | v Quality Check | v Production Deployment There is no mandatory manual approval between a successful pipeline and production deployment.
Remember:
- CI: Frequently integrate code and automatically verify it.
- Continuous Delivery: Keep software ready for release, with deployment potentially requiring approval.
- Continuous Deployment: Automatically deploy successful changes to production.
Jenkins can help implement all these practices.
Understanding Jenkins architecture
Now let's understand how Jenkins is structured internally.
Jenkins uses a distributed architecture consisting of two important components:
- Jenkins Controller.
- Jenkins Agents.
Jenkins controller and agents
Jenkins Controller
The controller is the central component of Jenkins.
It is responsible for:
- Managing Jenkins configuration.
- Managing jobs and pipelines.
- Scheduling builds.
- Managing agents.
- Tracking build results.
- Providing the web interface.
Think of the controller as the brain of Jenkins.
Jenkins Agent
An agent is a machine that performs the actual build and execution tasks assigned by the controller.
For example, the controller might assign the following work:
- Build a Java application.
- Run tests.
- Build a Docker image.
An agent receives this work and executes it.
Let's understand with a diagram.
JENKINS CONTROLLER +-------------+ | | | Schedule | | Jobs | | | | Manage | | Pipelines | | | +-------------+ | Assigns Work | +----------+----------+ | | v v +------------+ +------------+ | AGENT 1 | | AGENT 2 | | | | | | Java | | Docker | | Maven | | Kubernetes | | | | Tools | +------------+ +------------+ We can configure agents based on their capabilities.
For example:
- Java agent: Runs Java and Maven builds.
- Docker agent: Builds and publishes Docker images.
- Deployment agent: Has access to the Kubernetes cluster.
This allows Jenkins to distribute work across multiple machines.
Behind the scenes
- A developer triggers a pipeline.
- The controller receives the request.
- Jenkins identifies an available agent.
- The controller schedules the required work.
- The agent executes the pipeline steps.
- The agent returns the execution results.
- The controller updates the build status.
A Jenkins installation can also execute builds on its built-in node for small learning environments.
However, for production environments, Jenkins recommends keeping the controller focused on orchestration and using dedicated agents for build execution.
Why Jenkins uses plugins
One of the reasons Jenkins is widely used is its plugin architecture.
A plugin is an extension that adds functionality to Jenkins.
Imagine Jenkins without plugins.
It would provide its core automation capabilities, but it would not automatically know how to integrate with every external development tool.
Plugins extend those capabilities.
For example:
Git plugin
Allows Jenkins to retrieve source code from Git repositories.
GitHub integration plugins
Help Jenkins integrate with GitHub repositories, branches, and pull requests.
Pipeline plugin
Provides Pipeline functionality and the ability to define workflows as code.
Maven integration
Helps configure and integrate Maven-based builds.
SonarQube Scanner plugin
Integrates Jenkins pipelines with SonarQube analysis.
Docker-related plugins and tools
Help Jenkins interact with Docker-based build and deployment workflows.
Kubernetes plugin
Can dynamically provision Jenkins agents inside a Kubernetes cluster.
An important distinction:
Not every external tool requires a dedicated Jenkins plugin. Some tools can also be executed directly through shell commands on an agent.
For example:
sh 'mvn clean package' Jenkins can execute this command as long as Maven is available on the agent.
From source code to deployment
Now let's connect Jenkins with the tools we use during application development.
Consider a Spring Boot application.
Our development and deployment workflow may look like this:
DEVELOPER | | Push Code v GITHUB | | Webhook v JENKINS | v MAVEN | +------+------+ | | v v Compile Test | | +------+------+ | v PACKAGE JAR | v SONARQUBE | Quality Gate | v DOCKER | Docker Image | v IMAGE REGISTRY | v KUBERNETES | v RUNNING APPLICATION This is one common CI/CD workflow.
The exact sequence varies between organizations. For example, SonarQube analysis may happen as part of the Maven build command rather than as an entirely separate operation.
Let's understand the responsibility of each tool.
What each tool does
1. Developer
The developer writes application code and commits the changes.
For example:
@RestController public class HelloController { @GetMapping("/hello") public String hello() { return "Hello from Spring Boot!"; } } The developer pushes the code to GitHub.
2. GitHub
GitHub stores the source code in a Git repository.
It maintains:
- Source code.
- Branches.
- Commits.
- Pull requests.
- Project history.
When the developer pushes new code, GitHub can notify Jenkins through a webhook.
A webhook is an HTTP request sent by one application to another when a particular event occurs.
For example:
Developer pushes code | v GitHub receives commit | v GitHub sends webhook | v Jenkins starts pipeline 3. Jenkins
Jenkins receives the trigger and starts the configured pipeline.
It coordinates the remaining operations.
4. Maven
Maven builds the Java application.
It can:
- Compile Java source code.
- Resolve dependencies.
- Run tests.
- Package the application into a JAR or WAR file.
For example:
mvn clean package 5. SonarQube
SonarQube analyzes source code to identify issues related to code quality and security.
It helps developers identify:
- Bugs.
- Code smells.
- Security vulnerabilities.
- Duplicated code.
- Maintainability issues.
It can also calculate a Quality Gate status based on configured quality conditions.
Jenkins can stop the pipeline if the Quality Gate fails.
6. Docker
After the application is built and the required checks pass, Docker can package the application and its runtime dependencies into a container image.
For example:
docker build -t myapp:1.0 . This creates a Docker image named myapp with the tag 1.0.
7. Kubernetes
Kubernetes manages containerized applications.
It can:
- Deploy application containers.
- Maintain the desired number of replicas.
- Restart failed containers.
- Perform rolling updates.
- Manage service discovery and networking.
Jenkins can trigger Kubernetes deployment commands after the image is published to a container registry.
The important idea is:
Jenkins coordinates the entire process, while each tool performs its specific responsibility.
What is a Jenkins Pipeline?
Now let's understand one of the most important concepts in Jenkins.
A Jenkins Pipeline is a way of defining and automating the complete software delivery workflow.
It describes what tasks should be executed, in which order, and under what conditions.
For example:
JENKINS PIPELINE | v CHECKOUT | v BUILD | v TEST | v CODE ANALYSIS | v PACKAGE | v DEPLOY A pipeline connects multiple related operations into one automated workflow.
You can think of it as a sequence of stages and steps that work together to deliver an application.
However, a Jenkins Pipeline is not necessarily just a group of separate jobs.
It is a workflow model that can contain multiple stages, steps, conditions, parallel executions, and even trigger other Jenkins jobs.
Job vs pipeline
Before going further, let's understand the difference between a job and a pipeline.
Job
A Jenkins job represents a configured unit of work that Jenkins can execute.
For example:
- Build Java Application.
- Run Unit Tests.
- Deploy Application.
A job can be configured using different job types, including Freestyle projects and Pipeline projects.
Pipeline
A Pipeline defines a complete workflow containing multiple related operations.
For example:
JENKINS PROJECT | v PIPELINE | +---------+---------+ | | | v v v BUILD TEST DEPLOY A pipeline can perform these tasks inside one Pipeline job.
It can also trigger other jobs when that is useful.
So, remember:
- A job is a unit of work configured in Jenkins.
- A Pipeline is a workflow that describes how related tasks are executed.
Stages and steps
A Jenkins Pipeline commonly contains three important concepts:
- Pipeline.
- Stages.
- Steps.
Pipeline
The outer block defines the complete workflow.
pipeline { // Pipeline configuration } Stages
Stages represent major phases of the workflow.
For example:
- Checkout.
- Build.
- Test.
- Deploy.
stages { stage('Build') { // Build operations } stage('Test') { // Testing operations } stage('Deploy') { // Deployment operations } } Steps
Steps are the actual operations performed inside a stage.
For example:
stage('Build') { steps { echo 'Building application' sh 'mvn clean package' } } Here:
-
stage('Build')defines a stage. -
echoprints a message. -
shexecutes a shell command.
Let's visualize this hierarchy.
PIPELINE | +-------+-------+ | | v v STAGE 1 STAGE 2 BUILD TEST | | +---+---+ +---+---+ | | | | v v v v STEP STEP STEP STEP Maven Archive Unit Report Build Artifact Tests Results Jenkins executes the stages in the defined order by default.
If a stage fails, later stages normally do not execute unless the Pipeline is explicitly designed to handle that failure.
Pipelines also support parallel execution when multiple tasks do not depend on one another.
Declarative vs Scripted Pipeline
Jenkins supports two major Pipeline syntaxes.
1. Declarative Pipeline
Declarative Pipeline provides a structured way to define automation workflows.
It uses predefined sections such as:
pipelineagentstagesstagestepspost
Example:
pipeline { agent any stages { stage('Build') { steps { echo 'Building application' } } stage('Test') { steps { echo 'Running tests' } } } } The structure is easy to read and understand.
2. Scripted Pipeline
Scripted Pipeline uses Groovy-based scripting with more flexible programming constructs.
Example:
node { stage('Build') { echo 'Building application' } stage('Test') { echo 'Running tests' } } Scripted Pipeline provides greater flexibility for complex conditional logic and programming-style workflows.
Which should you learn first?
Start with Declarative Pipeline.
It provides a structured syntax and is generally easier for beginners to understand and maintain.
Create your first Jenkins Pipeline
Let's write our first pipeline.
We'll create a simple workflow containing three stages:
- Build.
- Test.
- Deploy.
The instructions will be stored in a file called:
Jenkinsfile A Jenkinsfile is a text file that contains the definition of a Jenkins Pipeline.
It is commonly stored in the root directory of your application's Git repository.
A minimal Jenkinsfile
Create a file named Jenkinsfile:
pipeline { agent any stages { stage('Build') { steps { echo 'Building application...' } } stage('Test') { steps { echo 'Running tests...' } } stage('Deploy') { steps { echo 'Deploying application...' } } } } Let's understand the syntax.
1. pipeline
pipeline { } Defines the complete Pipeline.
2. agent
agent any Specifies where the pipeline should execute.
any means Jenkins can use any available agent that satisfies the scheduling requirements.
3. stages
stages { } Contains the stages that make up the workflow.
4. stage
stage('Build') { } Defines an individual phase of the workflow.
5. steps
steps { echo 'Building application...' } Contains the actual operations performed in that stage.
Now we can create a Pipeline job in Jenkins.
A basic process is:
- Open the Jenkins dashboard.
- Select New Item.
- Enter a job name.
- Select Pipeline.
- Add the Pipeline script.
- Save the configuration.
- Click Build Now.
Expected output (simplified):
[Pipeline] Start of Pipeline [Pipeline] stage [Pipeline] { (Build) Building application... [Pipeline] } [Pipeline] stage [Pipeline] { (Test) Running tests... [Pipeline] } [Pipeline] stage [Pipeline] { (Deploy) Deploying application... [Pipeline] } [Pipeline] End of Pipeline Finished: SUCCESS The exact console formatting depends on the Jenkins version and installed plugins.
Congratulations! You've created your first Jenkins Pipeline.
Connect Jenkins to GitHub
So far, we have manually started the pipeline.
But in a real project, we want Jenkins to execute automatically whenever a developer pushes new code to GitHub.
Let's understand the process.
Step 1: Push the Jenkinsfile to GitHub
Your repository should contain something like this:
spring-boot-project/ | +-- src/ | +-- pom.xml | +-- Jenkinsfile | +-- README.md The Jenkinsfile defines the automation workflow.
Step 2: Create a Pipeline from SCM
Instead of writing the pipeline script directly in the Jenkins dashboard, configure Jenkins to retrieve it from source control.
SCM stands for Source Code Management.
For this, configure:
- Repository URL.
- Branch name.
- Credentials, if the repository is private.
- Script Path:
Jenkinsfile.
Jenkins will retrieve the project source and execute the pipeline defined in the Jenkinsfile.
Step 3: Configure a GitHub webhook
A webhook allows GitHub to notify Jenkins when a repository event occurs.
For example:
Developer | | git push v GitHub Repository | | Webhook notification v Jenkins | v Pipeline Execution A typical GitHub integration uses a Jenkins GitHub-related plugin and a configured webhook endpoint.
Jenkins must be reachable by GitHub for webhook delivery to work.
Step 4: Test the integration
Make a small change to your code.
For example, update the README file.
Commit and push:
git add . git commit -m "Update README" git push origin main If your webhook and pipeline trigger are configured correctly, Jenkins starts a new pipeline automatically.
Now you don't need to click Build Now every time.
Behind the scenes
- GitHub receives the push event.
- GitHub sends the webhook notification.
- Jenkins receives the notification.
- Jenkins identifies the relevant repository and branch.
- Jenkins retrieves the latest code.
- Jenkins executes the Jenkinsfile.
This is how GitHub and Jenkins work together to implement Continuous Integration.
Build with Maven and analyze with SonarQube
Now let's build something closer to a real Java backend project.
Suppose you have a Spring Boot application stored in GitHub.
You want Jenkins to:
- Download the source code.
- Build the application using Maven.
- Run unit tests.
- Package the application.
- Analyze the code using SonarQube.
- Check whether the Quality Gate passes.
Let's understand the responsibility of each tool first.
What Maven and SonarQube do
Maven
Maven is a build automation and dependency management tool used in Java projects.
It handles operations such as:
- Dependency management.
- Source code compilation.
- Running tests.
- Packaging the application.
For example:
mvn clean verify This executes Maven's clean lifecycle and the default build lifecycle up to the verify phase.
The build lifecycle includes compilation, testing, packaging, and verification.
For a typical Spring Boot project, Maven generates a JAR file inside the target directory.
Example:
spring-boot-project/ | +-- src/ | +-- pom.xml | +-- target/ | +-- spring-boot-project.jar SonarQube
SonarQube is a platform for analyzing source code quality and security.
It identifies issues such as:
- Bugs.
- Security vulnerabilities.
- Code smells.
- Duplicated code.
SonarQube can also evaluate code against a configured Quality Gate.
For example:
SONARQUBE ANALYSIS | +---------+---------+ | | v v Quality Quality Gate Gate PASS FAIL | | v v Continue Pipeline Stop Pipeline Jenkins can wait for SonarQube to complete the analysis and receive the Quality Gate result.
If the result fails, Jenkins can stop the pipeline before it reaches deployment.
A practical Jenkinsfile
Now let's combine Jenkins, Maven, and SonarQube.
Create the following Jenkinsfile in the root of your Spring Boot project:
pipeline { agent any stages { stage('Checkout') { steps { checkout scm } } stage('Build, Test and Package') { steps { sh 'mvn -B clean verify' archiveArtifacts( artifacts: 'target/*.jar', fingerprint: true ) } } stage('SonarQube Analysis') { steps { withSonarQubeEnv('SonarQube') { sh 'mvn -B sonar:sonar' } } } stage('Quality Gate') { steps { timeout(time: 5, unit: 'MINUTES') { waitForQualityGate( abortPipeline: true ) } } } } post { always { junit( testResults: '**/target/surefire-reports/*.xml', allowEmptyResults: true ) } } } Before using this example, configure the following in Jenkins:
- Git and Pipeline plugins.
- The Maven executable on the selected agent.
- SonarQube Scanner for Jenkins plugin.
- SonarQube server connection under Jenkins system configuration.
- SonarQube authentication credentials.
- A SonarQube webhook pointing to the Jenkins endpoint ending in
/sonarqube-webhook/.
Let's understand the important stages.
Stage 1: Checkout
stage('Checkout') { steps { checkout scm } } This retrieves the source code from the configured source control repository.
Stage 2: Build, Test and Package
stage('Build, Test and Package') { steps { sh 'mvn -B clean verify' } } Here Jenkins executes Maven.
Let's break down the command:
-
mvn: Execute Maven. -
-B: Run in batch mode, suitable for automated environments. -
clean: Remove output from a previous build. -
verify: Run the default lifecycle through the verification phase.
Maven compiles the code, executes tests, and packages the application.
For a typical Spring Boot project, the JAR is generated inside target/.
Next:
archiveArtifacts( artifacts: 'target/*.jar', fingerprint: true ) This tells Jenkins to store the generated JAR as a build artifact and fingerprint it.
Stage 3: SonarQube Analysis
withSonarQubeEnv('SonarQube') { sh 'mvn -B sonar:sonar' } This executes SonarQube analysis using Maven.
SonarQube is the name of the SonarQube server installation configured in Jenkins.
The plugin provides the necessary connection environment to the Maven scanner.
SonarQube processes the analysis and calculates the project's Quality Gate status.
Stage 4: Quality Gate
waitForQualityGate( abortPipeline: true ) This waits for SonarQube to complete the analysis.
If the Quality Gate fails, Jenkins aborts the pipeline.
The timeout ensures that Jenkins does not wait indefinitely.
The SonarQube webhook is required for this integration to notify Jenkins when the analysis finishes.
Post section
post { always { junit( testResults: '**/target/surefire-reports/*.xml', allowEmptyResults: true ) } } This publishes available JUnit test reports after the pipeline finishes.
The always condition means Jenkins attempts this operation whether the pipeline succeeds or fails.
How the pipeline executes
Let's understand the complete flow.
GITHUB | v CHECKOUT | v MAVEN | +--------+--------+ | | | v v v Compile Tests Package | v JAR FILE | v SONARQUBE | v QUALITY GATE | +-------+-------+ | | v v PASS FAIL | | v v Next Pipeline Stop Pipeline Stage This is how Jenkins coordinates Maven and SonarQube.
Notice something:
Maven creates the JAR during the build. SonarQube then analyzes the source code, and the Quality Gate determines whether the pipeline should continue.
The application can proceed to containerization and deployment only after the required checks pass.
Docker and Kubernetes
Our application is now built and analyzed.
What's next?
We need to deploy it.
This is where Docker and Kubernetes can be integrated into the Jenkins pipeline.
Docker
Docker packages an application and its required runtime environment into a container image.
For example:
docker build -t my-spring-app:1.0 . Jenkins can execute this command inside a Docker-capable agent.
The generated image can then be pushed to a container registry.
Examples of container registries include:
- Docker Hub.
- Amazon Elastic Container Registry.
- Azure Container Registry.
- Google Artifact Registry.
Kubernetes
Kubernetes manages the deployment and operation of containerized applications.
After pushing the image to a registry, Jenkins can trigger Kubernetes deployment.
For example:
kubectl set image deployment/my-app \ my-app=registry.example.com/my-spring-app:1.0 This updates the image used by the my-app container in an existing Kubernetes Deployment.
The agent must have access to Docker, kubectl, the registry credentials, and the Kubernetes cluster credentials.
Let's visualize the complete workflow.
DEVELOPER | v GITHUB | v JENKINS | +------+------+ | | v v MAVEN SONARQUBE | | v v BUILD QUALITY GATE | | +------+------+ | v JAR FILE | v DOCKER | v DOCKER IMAGE | v CONTAINER REGISTRY | v KUBERNETES | v RUNNING APPLICATION This is a typical end-to-end CI/CD workflow for a Java application.
Remember that the exact deployment process depends on your infrastructure. Jenkins can also deploy directly to virtual machines, cloud platforms, or other environments without Kubernetes.
Which one should I use?
We have discussed several tools and concepts.
Let's understand their responsibilities.
1. Jenkins vs Maven
Use Jenkins when you need to automate and coordinate the complete software delivery workflow.
Use Maven when you need to build, test, and package Java applications.
They complement each other.
2. Jenkins vs GitHub
Use GitHub to store and manage source code.
Use Jenkins to automate processes triggered by changes to that source code.
GitHub can notify Jenkins whenever new code is pushed.
3. Jenkins vs SonarQube
Use Jenkins to coordinate build and delivery operations.
Use SonarQube to analyze code quality and security.
Jenkins can use the Quality Gate result to decide whether a pipeline should continue.
4. Jenkins vs Docker
Use Jenkins to automate your build and deployment workflow.
Use Docker to package and run applications in containers.
5. Jenkins vs Kubernetes
Use Jenkins to automate deployment operations.
Use Kubernetes to manage running containerized applications.
My default approach for a Spring Boot project:
Start with:
GitHub | v Jenkins | v Maven | v Unit Testing | v SonarQube | v Docker | v Container Registry | v Kubernetes Add each tool when you have a real requirement for it. You don't need the complete toolchain for every project.
Common mistakes
Here are six mistakes beginners commonly make while learning Jenkins.
Thinking Jenkins is a build tool: Jenkins coordinates the workflow, while Maven or Gradle performs the actual application build. Understand the responsibility of each tool.
Confusing a job with a pipeline: A job is a configured unit of work. A Pipeline defines a workflow made up of stages and steps, and it can also trigger other jobs.
Thinking a Jenkinsfile is YAML: Jenkinsfiles generally use Groovy-based Declarative or Scripted Pipeline syntax. YAML is used by many other DevOps tools, but not for defining standard Jenkins Pipelines.
Running every task on the Jenkins controller: The controller should focus on managing and scheduling work. Use agents to execute resource-intensive builds.
Hardcoding credentials in Jenkinsfiles: Never store GitHub tokens, SonarQube tokens, or Docker passwords directly in source code. Use Jenkins Credentials and reference credentials by ID.
Deploying without checking build results: A successful checkout does not mean an application is ready for deployment. Run tests, perform quality checks, and enforce the required Quality Gate before releasing the application.
Quick recap
Let's quickly revise everything we learned.
Jenkins
- Free and open-source automation server.
- Used to automate software building, testing, and deployment.
- Supports CI/CD implementation.
- Extensible through plugins.
CI/CD
- CI: Continuous Integration.
- Continuous Delivery: Keep software ready for release.
- Continuous Deployment: Automatically release successful changes to production.
Architecture
- Controller: Manages Jenkins and schedules work.
- Agent: Executes assigned pipeline tasks.
- Plugins: Extend Jenkins functionality.
Pipeline
- Jenkins Pipeline: Defines an automated software delivery workflow.
- Job: A configured unit of work.
- Stage: A major phase of a pipeline.
- Step: An individual operation inside a stage.
- Jenkinsfile: File containing the Pipeline definition.
- Declarative Pipeline: Structured Pipeline syntax.
- Scripted Pipeline: More flexible Groovy-based syntax.
Toolchain
- GitHub: Stores source code.
- Jenkins: Coordinates automation.
- Maven: Builds and packages Java applications.
- SonarQube: Analyzes code quality and security.
- Docker: Builds container images.
- Kubernetes: Manages containerized applications.
Remember this simple idea:
DEVELOPER | v GITHUB | v JENKINS | v BUILD | v TEST | v CODE QUALITY | v PACKAGE | v DOCKER | v KUBERNETES | v APPLICATION RUNNING Jenkins connects all these individual operations into one automated workflow.
Try it yourself
Practice idea:
Create a simple Spring Boot application and push it to GitHub.
Add a Jenkinsfile containing three stages:
- Checkout: Retrieve the source code.
- Build: Execute
mvn clean package. - Test: Execute or report your unit tests.
Configure Jenkins to retr...
