☑️Day 49: Basic Hands-On Practice with Jenkins Jobs🚀

🔹Table of Contents :
Introduction
Task 1: Creating a Simple Freestyle Job
Task 2: Creating a Simple Pipeline Job
Real-Time Scenarios for Jenkins Jobs
Key Takeaways
Today, I explored the basics of Jenkins by working on two tasks that involved creating Jenkins jobs. This hands-on practice helped me understand how to configure and execute jobs using Jenkins, which is an essential skill in the DevOps world. Let’s dive into the details of what I learned and performed.
✅Why Jenkins Jobs Matter
Jenkins Jobs are the core tasks that Jenkins executes, allowing automation of various processes such as building code, running tests, and deploying applications.
Jenkins supports different types of jobs, including Freestyle Jobs and Pipeline Jobs. Each type serves a specific purpose and supports different use cases.
✅Task 1: Creating a Simple Freestyle Job
Step-by-Step Process:
Create a New Freestyle Job:
In Jenkins, click on "New Item".
Enter the name for the job (e.g., "Basic Freestyle Job").
Select "Freestyle project" and click "OK".
Configure the Build Steps:
In the job configuration, scroll down to the "Build" section.
Click on "Add build step" and select "Execute shell".
Add the following commands in the script box:
echo "Hello friends" echo "Started learning Jenkins" mkdir -p devops echo "DevOps folder created"Explanation of the Commands:
echo "Hello friends"Displays the message "Hello friends" in the build logs.
echo "Started learning Jenkins"Displays "Started learning Jenkins" in the logs.
mkdir -p devopsCreates a new directory named "devops" if it doesn't already exist. The
-pflag ensures no errors occur if the directory is already there.echo "DevOps folder created"Confirms the folder creation by displaying this message in the logs.
Save the Job Configuration:
- Click on "Save" to store the job configuration.
Build the Job:
Click on "Build Now" to execute the job.
Once the build is complete, check the "Console Output" to verify the commands executed successfully.
Verify Job Execution:
To ensure that the "devops" directory was created, go to the Jenkins server and navigate to the workspace of the job.
Confirm that the "devops" directory is present.
✅Task 2: Creating a Simple Pipeline Job
Step-by-Step Process:
Create a New Pipeline Job:
In Jenkins, click on "New Item".
Enter the name for the job (e.g., "Basic Pipeline Job").
Select "Pipeline" and click "OK".
Configure the Pipeline Script:
In the job configuration, scroll down to the "Pipeline" section.
Choose "Pipeline script" and add the following simple script:
pipeline { agent any stages { stage('Hello') { steps { echo 'Hello, world!' } } stage('Create Directory') { steps { sh 'mkdir -p devops' } } stage('Goodbye') { steps { echo 'Bye, world!' } } } }Explanation of the Pipeline Script:
pipeline {}: Defines the Jenkins pipeline structure.agent any: Runs the pipeline on any available Jenkins agent.stages {}: Contains a series of stages that the pipeline will execute sequentially.Stage 1: "Hello": Prints "Hello, world!" in the build logs.
Stage 2: "Create Directory": Executes the shell command
mkdir -p devopsto create the "devops" directory.Stage 3: "Goodbye": Prints "Bye, world!" in the logs.
Save and Execute the Pipeline:
Click on "Save" to store the pipeline job configuration.
Click on "Build Now" to execute the pipeline.
Check the Build Logs:
View the "Console Output" to confirm each stage executed successfully.
The logs will display the output for each stage, verifying the commands.
✅Real-Time Scenarios for Jenkins Jobs
Freestyle Jobs are great for simple automation tasks like running shell scripts, building small projects, or performing routine checks.
Pipeline Jobs are more suitable for complex workflows, such as multi-stage builds, deployments, or integrating with other tools.
Example:
Freestyle Job can automate creating directories for new projects.
Pipeline Job can automate the build, test, and deploy cycle for an application.
✅Key Takeaways
Learned the basics of creating Freestyle and Pipeline jobs.
Practiced executing shell commands and working with Jenkins Pipeline scripts.
Understood the differences between Freestyle and Pipeline jobs.
Gained hands-on experience with job configuration and verifying outputs.
🚀Thanks for joining me on Day 49! Let’s keep learning and growing together!
Happy Learning! 😊
#90DaysOfDevOps




