This is #90DaysofDevops challenge under the guidance of Shubham Londhe sir.
Task 1: Understanding Jenkins
Jenkins is an open-source automation server widely used in the software development lifecycle for automating various tasks, including building, testing, and deploying applications. It serves as the backbone of continuous integration (CI) and continuous delivery (CD) pipelines, enabling teams to automate repetitive tasks and streamline the software development process. Here's a detailed explanation of Jenkins:
Automation Server: Jenkins acts as an automation server, orchestrating and executing various tasks involved in the software development process. It automates tasks such as building code, running tests, deploying applications, and generating reports.
Continuous Integration (CI): One of Jenkins' primary functions is continuous integration, where it automatically builds and tests code changes as soon as they are committed to the version control repository. Jenkins integrates with version control systems like Git, SVN, and others to fetch code changes and trigger build jobs.
Continuous Delivery (CD): Jenkins also supports continuous delivery, which extends the concept of continuous integration to automate the deployment process. It allows teams to deploy code changes to production or staging environments in an automated and reliable manner, reducing the risk of human errors and ensuring consistent deployments.
Extensibility and Plugins: Jenkins is highly extensible and comes with a vast ecosystem of plugins that extend its functionality. Plugins are available for integrating Jenkins with various tools, technologies, and services, allowing users to customize and tailor Jenkins to their specific requirements. Users can install plugins to integrate Jenkins with version control systems, build tools, testing frameworks, deployment platforms, and more.
Pipelines: Jenkins introduces the concept of pipelines, which represent a series of steps that define the software delivery process. Pipelines are defined using a Jenkinsfile, which is a text file written in a domain-specific language called Groovy. Pipelines allow users to define complex workflows, including building, testing, and deploying applications, in a structured and repeatable manner.
Distributed Builds: Jenkins supports distributed builds, allowing users to distribute build jobs across multiple nodes or agents. This helps distribute the workload and improve build performance by leveraging resources available on different machines. Jenkins can dynamically allocate build jobs to available nodes based on workload and resource availability.
Monitoring and Reporting: Jenkins provides comprehensive monitoring and reporting capabilities, allowing users to track the status and progress of build jobs, tests, and deployments. It generates detailed reports, logs, and visualizations that provide insights into the health and performance of the software development process. Users can analyze build trends, identify issues, and make data-driven decisions to improve the quality and efficiency of their software delivery pipeline.
Community and Support: Jenkins boasts a vibrant community of users, contributors, and developers who actively contribute to its development and maintenance. The community provides support, documentation, tutorials, and forums where users can seek assistance, share best practices, and collaborate with others. Jenkins also has commercial support options available from vendors offering enterprise-grade solutions and services.
Installation of Jenkins:
Before diving into creating a freestyle pipeline, let's ensure you have Jenkins installed and ready to roll. Follow these steps for a seamless installation:
Step 1: Install Java
Update the package repository:
sudo apt update
Install OpenJDK (Java Development Kit):
sudo apt install fontconfig openjdk-17-jre
Verify Java installation:
java -version
Step 2: Install Jenkins
Add the Jenkins repository key:
sudo wget -O /usr/share/keyrings/jenkins-keyring.asc \
https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
Add the Jenkins repository to your system:
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 the package repository again:
sudo apt-get update
Install Jenkins:
sudo apt-get install jenkins
Start Jenkins service:
sudo systemctl start jenkins
Enable Jenkins to start on boot:
sudo systemctl enable jenkins
Check the status of Jenkins:
sudo systemctl status jenkins
Now, you can access Jenkins in your web browser by navigating to http://localhost:8080
. Follow the on-screen instructions to unlock Jenkins and complete the initial setup.
Task 2: Creating a Freestyle Pipeline
Step 1: Accessing Jenkins Dashboard
Open your web browser and navigate to the URL where Jenkins is installed.
Log in to the Jenkins dashboard using your credentials.
Step 2: Creating a New Item
Once logged in, click on the "New Item" option on the left-hand side menu.
Enter a suitable name for your project, such as "Hello World Pipeline," and select "Freestyle project."
Step 3: Configuring the Pipeline
In the project configuration page, navigate to the "Build" section.
Click on the "Add build step" dropdown and select either "Execute shell" (for Unix-based systems) or "Execute Windows batch command" (for Windows systems).
In the command area, type the command
echo "Hello World!!"
to print "Hello World!!" when the pipeline runs.
Step 4: Saving the Configuration
- Scroll down to the bottom of the page and click on the "Save" button to save your pipeline configuration.
Step 5: Running the Pipeline
Return to the Jenkins dashboard and locate your newly created pipeline project.
Click on the project name to view its details.
From the project dashboard, click on "Build Now" to trigger a build of the pipeline.
Step 6: Viewing the Console Output
Once the build is triggered, Jenkins will execute the pipeline according to the configured steps.
Click on the build number to view the console output, which will display the "Hello World!!" message.
Congratulations! You have successfully created and executed a simple freestyle pipeline in Jenkins to print "Hello World!!" This hands-on experience demonstrates the basic functionality of Jenkins pipelines and sets the foundation for more advanced CI/CD workflows.
Stay tuned for more tutorials and insights on Jenkins and other DevOps tools to further enhance your automation skills! ๐