Skip to main content

Command Palette

Search for a command to run...

Day 22 :- Getting Started with Jenkins.

Updated
4 min read
Day 22 :-  Getting Started with Jenkins.

WHAT IS JENKINS :-

Jenkins is an open-source automation server that facilitates the continuous integration and continuous delivery (CI/CD) of software projects. It is written in Java and offers a vast array of plugins to support building, deploying, and automating any project.

At its core, Jenkins allows developers to automate various tasks related to software development, including building, testing, and deploying applications. It integrates with version control systems like Git, Subversion, and Mercurial, allowing it to trigger builds automatically whenever changes are pushed to the repository. This automation helps ensure that software changes are thoroughly tested and integrated into the project in a timely manner.

One of Jenkins' key features is its extensibility through plugins. These plugins expand Jenkins' functionality to support a wide range of tools and technologies, making it highly customizable to fit the specific needs of different development teams. Users can install plugins for source code management, build automation, testing frameworks, deployment tools, and more.

Jenkins operates through a web-based interface, making it accessible from anywhere with an internet connection. Developers can configure and manage their Jenkins jobs through this interface, setting up build pipelines and workflows tailored to their project requirements. Jenkins also provides detailed logs and reports, helping teams track the progress of builds and diagnose any issues that may arise.

Overall, Jenkins is a powerful tool for automating the software development lifecycle, enabling teams to deliver high-quality software faster and more efficiently. Its flexibility, extensibility, and robust feature set have made it a popular choice for organizations of all sizes seeking to implement CI/CD best practices in their development workflows.

How to install Jenkins :-

Installing Jenkins can vary slightly depending on your operating system. Here, I'll provide a general overview of the steps to install Jenkins:

  1. System Requirements: Make sure your system meets the minimum requirements for running Jenkins. Typically, Jenkins runs on Java, so ensure you have Java installed on your system.

  2. Download Jenkins: Visit the official Jenkins website at https://www.jenkins.io/ and navigate to the download page. You can download the Jenkins WAR (Web Application Archive) file or choose a package suitable for your operating system.

  3. Installation on Linux:

    • Debian/Ubuntu: You can install Jenkins using the Debian package repository. Add the repository key, add the repository to your system, update package index, and finally install Jenkins using the package manager.
    wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
    sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
    sudo apt-get update
    sudo apt-get install jenkins
  • Red Hat/CentOS: For Red Hat-based systems, you can use the RPM package. Download the RPM file and install it using yum or dnf.
  1. Installation on Windows:

    • Download the Jenkins MSI (Microsoft Installer) package from the Jenkins website.

    • Run the MSI installer and follow the on-screen instructions. Jenkins will be installed as a Windows service.

  2. Start Jenkins: Once installed, start the Jenkins service.

    • Linux: Use systemctl or service command to start the Jenkins service.

    • Windows: Jenkins service should start automatically after installation. You can also manually start it from the Services app.

  3. Access Jenkins: Jenkins web interface is accessible through a web browser. Open your browser and navigate to `http://localhost:

    Creating a freestyle pipeline to print "hello world" :-

To create a freestyle pipeline in Jenkins to print "Hello World!!", follow these steps:

  1. Access Jenkins Dashboard: Open your web browser and navigate to Jenkins by entering http://localhost:8080 (if Jenkins is installed locally) or the appropriate IP address if installed on a server.

  2. Create a New Freestyle Project:

    • Click on "New Item" on the Jenkins dashboard.

    • Enter a name for your project, such as "HelloWorld", and select "Freestyle project".

    • Click "OK" to create the project.

  3. Configure the Project:

    • Under the "General" section, you can provide a description if needed.

    • Under the "Build" section, click on "Add build step" and select "Execute shell" (for Linux/Mac) or "Execute Windows batch command" (for Windows).

    • In the command box, type the command to print "Hello World!!". For example, in Linux/Mac:

        echo "Hello World!!"
      
  4. Save the Configuration: Click on "Save" to save the configuration of your freestyle project.

  5. Build the Project:

    • On the project dashboard, click on "Build Now" to trigger a build.

    • Once the build is complete, click on the build number to view the console output.

You should see "Hello World!!" printed in the console output, indicating that your freestyle pipeline successfully executed the command. This simple pipeline demonstrates the basic functionality of Jenkins in executing commands as part of a build process.