🕵️ SicherheitslückenThe Cyber Mentors: 3 Cybersecurity Books to Read(01.09.2026 um 19:00 Uhr)
🕵️ SicherheitslückenMy Life, AI and the Future of LiveOverflow(23.08.2026 um 19:53 Uhr)
🕵️ SicherheitslückenThe XSS Rat: How To Use AI To Become a KiLLER Hacker(29.08.2026 um 02:05 Uhr)
⚠️ Malware / Trojaner / VirenPC Security Channel: How North Korean Hackers end up in your Network(24.08.2026 um 20:30 Uhr)
⚠️ Malware / Trojaner / VirenPC Security Channel: Undetected Steam Malware: Sent by Viewer(28.08.2026 um 21:00 Uhr)
⚠️ Malware / Trojaner / VirenPC Security Channel: How to tell if your PC is Hacked: Ultimate Edition(04.09.2026 um 20:30 Uhr)
🕵️ SicherheitslückenSecurity Weekly - A CRA Resource: What AI Researchers See Beyond AI(01.09.2026 um 15:00 Uhr)
🕵️ SicherheitslückenThe Cyber Mentors: 3 Cybersecurity Books to Read(01.09.2026 um 19:00 Uhr)
🕵️ SicherheitslückenMy Life, AI and the Future of LiveOverflow(23.08.2026 um 19:53 Uhr)
🕵️ SicherheitslückenThe XSS Rat: How To Use AI To Become a KiLLER Hacker(29.08.2026 um 02:05 Uhr)
⚠️ Malware / Trojaner / VirenPC Security Channel: How North Korean Hackers end up in your Network(24.08.2026 um 20:30 Uhr)
⚠️ Malware / Trojaner / VirenPC Security Channel: Undetected Steam Malware: Sent by Viewer(28.08.2026 um 21:00 Uhr)
⚠️ Malware / Trojaner / VirenPC Security Channel: How to tell if your PC is Hacked: Ultimate Edition(04.09.2026 um 20:30 Uhr)
🕵️ SicherheitslückenSecurity Weekly - A CRA Resource: What AI Researchers See Beyond AI(01.09.2026 um 15:00 Uhr)

🔧 Programmierung 🕛 kürzlich 6 Min Lesezeit
0

Understanding Jenkins CI/CD Using a Tiny Java Project (A Beginner-Friendly Walkthrough)

↗ Quelle (dev.to)
🗣️ Stimme:
📑 Inhaltsübersicht




Understanding Jenkins CI/CD Using a Tiny Java Project



Most Jenkins tutorials immediately jump into Docker, Kubernetes, Maven, cloud deployments, and enterprise-scale architectures.



For someone learning CI/CD for the first time, that can become overwhelming very quickly.



In this article, we'll build a very lightweight but real Jenkins pipeline using a simple Java application. The goal is to understand how Jenkins works behind the scenes before introducing more advanced DevOps tools.



This example demonstrates:




  • Pipeline stages

  • Compilation

  • Program execution

  • Artifact generation

  • Artifact archiving

  • Jenkins workspace concepts

  • Console output debugging



without introducing unnecessary complexity.









Why This Example?



Whether you're building:




  • A Java application

  • A Spring Boot service

  • A Docker image

  • A Kubernetes deployment



the fundamental Jenkins workflow remains largely the same:




CODE
Source Code

Build

Test

Package

Deploy









Understanding this flow first makes learning advanced CI/CD concepts much easier.





Figure 1: Simplified Jenkins CI/CD flow used throughout this tutorial.





Environment



The following environment was used:




CODE
Ubuntu 24.04 LTS
OpenJDK 17
Git
Jenkins












Jenkins Installation



Before creating Jenkins pipelines, Jenkins must be installed on the system.



Since Jenkins runs on Java, Java must be installed first.






Update Package Information






CODE
sudo apt update









Verify Java Installation






CODE
java -version






If Java is not installed:




CODE
sudo apt install openjdk-17-jdk






Verify Java again:




CODE
java -version









Add Jenkins Repository Key






CODE
curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee \
/usr/share/keyrings/jenkins-keyring.asc > /dev/null









Add Jenkins Repository






CODE
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









Update Package Information Again






CODE
sudo apt update









Install Jenkins






CODE
sudo apt install jenkins









Start Jenkins Service






CODE
sudo systemctl start jenkins









Enable Jenkins at Startup






CODE
sudo systemctl enable jenkins









Verify Jenkins Status






CODE
sudo systemctl status jenkins









Open Jenkins in Browser






CODE
http://localhost:8080






During the first login, Jenkins requests an administrator password.



Retrieve it using:




CODE
sudo cat /var/lib/jenkins/secrets/initialAdminPassword






Copy the password and complete the Jenkins setup wizard.









Project Structure



The project is intentionally very small.




CODE
calculator-app/

├── src/
│ └── Main.java

└── Jenkinsfile












Java Application



Create:




CODE
src/Main.java









CODE
public class Main {

public static void main(String[] args) {

int a = 10;
int b = 20;

int sum = a + b;

System.out.println("Sum = " + sum);
}
}






When executed:




CODE
Sum = 30






Although the application is tiny, it exercises the same Jenkins concepts used in larger CI/CD pipelines.









Jenkins Pipeline



Create:




CODE
Jenkinsfile









CODE
pipeline {

agent any

stages {

stage('Preparation') {
steps {
echo 'Preparing build environment...'
}
}

stage('Compile') {
steps {

dir('/mnt/c/MyDomain/jenkin-work/apps/calculator-app') {

echo 'Compiling Java program...'

sh 'javac src/Main.java'
}
}
}

stage('Run Program') {
steps {

dir('/mnt/c/MyDomain/jenkin-work/apps/calculator-app') {

echo 'Running Java program...'

sh 'java -cp src Main > output.txt'
}
}
}

stage('Archive Output') {
steps {

dir('/mnt/c/MyDomain/jenkin-work/apps/calculator-app') {

archiveArtifacts artifacts: 'output.txt'
}
}
}

stage('Deploy Simulation') {
steps {
echo 'Deploying application...'
}
}
}

post {

success {
echo 'Pipeline executed successfully!'
}

failure {
echo 'Pipeline failed!'
}
}
}







Note



For simplicity, this tutorial uses a hardcoded project path:




CODE
dir('/mnt/c/MyDomain/jenkin-work/apps/calculator-app')



This was intentionally done to demonstrate an important Jenkins workspace concept and keep the example lightweight.



In real-world CI/CD pipelines, Jenkins typically checks out source code directly from a Git repository into its workspace.



A more typical approach would look like:




CODE
stage('Checkout') {
steps {
git 'https://github.com/your-username/calculator-app.git'
}
}

stage('Compile') {
steps {
sh 'javac src/Main.java'
}
}



The purpose of this article is to focus on understanding pipeline execution, workspaces, artifacts, and build flow before introducing Git integration.










Understanding Each Stage






Preparation






CODE
echo 'Preparing build environment...'






This stage simulates environment preparation.



In larger projects, this could include:




  • Loading credentials

  • Installing dependencies

  • Setting environment variables









Compile






CODE
sh 'javac src/Main.java'






Compiles the Java source code.



If compilation fails, the pipeline stops immediately.









Run Program






CODE
sh 'java -cp src Main > output.txt'






Executes the application and redirects the output to:




CODE
output.txt






Contents:




CODE
Sum = 30












Archive Output






CODE
archiveArtifacts artifacts: 'output.txt'






Stores the generated file inside Jenkins for later access.









Deploy Simulation






CODE
echo 'Deploying application...'






In a production pipeline, this stage could:




  • Deploy Docker containers

  • Copy files to servers

  • Deploy applications to Kubernetes

  • Restart services









Creating the Jenkins Pipeline Job



After logging into Jenkins:




  1. Click:




CODE
New Item







  1. Enter:




CODE
calculator-pipeline







  1. Select:




CODE
Pipeline







  1. Click OK


  2. Under:





CODE
Definition






Choose:




CODE
Pipeline Script







  1. Paste the Jenkinsfile content.


  2. Save.


  3. Click:





CODE
Build Now












CI/CD Flow Visualization






CODE
          Java Source Code


Jenkins Pipeline Starts


Compile


Execute


Generate Artifact


Archive Artifact


Post Actions






Although this example is small, enterprise pipelines follow the same basic pattern.









Understanding Jenkins Workspaces



One of the most important Jenkins concepts is the workspace.



When Jenkins executes a build, it typically runs inside:




CODE
/var/lib/jenkins/workspace/calculator-pipeline






My initial build failed because Jenkins could not locate:




CODE
src/Main.java






The source code existed outside the Jenkins workspace.



The solution was:




CODE
dir('/mnt/c/MyDomain/jenkin-work/apps/calculator-app') {

sh 'javac src/Main.java'
}






This temporarily changes the working directory before executing commands.



Understanding workspaces will save significant debugging time when building larger pipelines.









Console Output



A successful build produced output similar to:




CODE
Preparing build environment...
Compiling Java program...
Running Java program...
Pipeline executed successfully!






The Jenkins Console Output page is often the first place you'll inspect when troubleshooting build failures.









Generated Artifact



The pipeline generated:




CODE
output.txt






Contents:




CODE
Sum = 30






Real-world pipelines commonly generate:




  • JAR files

  • WAR files

  • Test reports

  • Coverage reports

  • Docker images

  • Deployment packages



The concept remains identical.









The Most Important Lesson



💡 Key Takeaway



Jenkins does not compile Java, build Docker images, or deploy applications itself.



Jenkins is an automation server that orchestrates external tools and commands.



Understanding this distinction is one of the most important concepts in DevOps and CI/CD.



When Jenkins executes:




CODE
sh 'javac src/Main.java'






it is simply asking the operating system to run the Java compiler.



Likewise:




CODE
sh 'docker build .'






asks Docker to build an image.



Jenkins orchestrates tools—it does not replace them.



Understanding this distinction is fundamental to learning DevOps and CI/CD.









Future Enhancements



Once comfortable with this example, you can gradually introduce:




  • Git integration

  • Automatic build triggers

  • Maven builds

  • Unit testing

  • Docker integration

  • Tomcat deployment

  • Kubernetes deployment

  • Full CI/CD automation



The core Jenkins concepts remain exactly the same.









Final Thoughts



Many engineers first encounter Jenkins through large enterprise pipelines that can feel intimidating.



Starting with a tiny project makes the learning process much easier.



A simple Java application is enough to understand:




  • Pipeline stages

  • Build execution

  • Artifacts

  • Workspaces

  • Automation flow



Once these fundamentals become clear, moving toward Docker, Kubernetes, and enterprise CI/CD becomes much more natural.



Sometimes the best way to understand a large system is to begin with the smallest possible working example.



If you're new to Jenkins, try building this example yourself before moving on to Maven, Docker, or Kubernetes. The concepts learned here will transfer directly to larger CI/CD pipelines.

Vollständiger Original-Bericht
Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 53%
🟡 In Evaluierung 24%
🟢 Keine Auswirkung 18%
Spannende Innovation 5%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
1 Quelle
ChatGPT showing blank screen [Fix]
1 Quelle
Sofort deinstallieren: Diese 19 Browser-Erweiterungen sind mit Malware verseucht
1 Quelle
AMD Ryzen AI 400 NPU einrichten: 60 TOPS in 12 Schritten [2026] - shattered.io
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Understanding Jenkins CI/CD Using a Tiny Java Project (A Beginner-Friendly Walkthrough)

Thematisch verwandte Begriffe: Understanding, Jenkins, CICD, Using · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...