Skip to main content

What is Jenkins? How to create pipeline using jenkins

 

What is Jenkins? (Simple Explanation for Students)

🔧 Jenkins is a free tool used by developers to automate tasks like:

  • Building code

  • Testing code

  • Deploying applications

💡 Think of Jenkins as a Robot Assistant:

Whenever you write code and push it to GitHub, Jenkins can:

  • Automatically test if the code works

  • Automatically build the app

  • Automatically deploy it to a server

🔁 This process is called CI/CD:

  • CI – Continuous Integration (build + test automatically)

  • CD – Continuous Deployment (deploy automatically)


🚀 Jenkins Installation: Key Steps and Important Options

🔷 Windows Installation Steps:

  1. Install Java First (JDK)
    Jenkins needs Java to run.

    • Download JDK from Oracle or OpenJDK

    • Set JAVA_HOME environment variable

    • Add Java to system PATH

  2. Download Jenkins

  3. Run Installer

    • Double-click and follow steps

    • It will install Jenkins as a Windows Service

  4. Initial Setup

    • Go to http://localhost:8080

    • Unlock Jenkins using the password in the file shown on screen

      • Path: C:\Program Files\Jenkins\secrets\initialAdminPassword

    • Install Suggested Plugins (Recommended)

    • Create Admin User

  5. Ready to Use!


🔷 Linux Installation Steps (Ubuntu/Debian Example):

  1. Install Java


    sudo apt update sudo apt install openjdk-17-jdk -y
  2. Add Jenkins Repository

    bash

    curl -fsSL https://pkg.jenkins.io/debian/jenkins.io-2023.key | sudo tee \ /usr/share/keyrings/jenkins-keyring.asc > /dev/null echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \ https://pkg.jenkins.io/debian binary/ | sudo tee \ /etc/apt/sources.list.d/jenkins.list > /dev/null
  3. Install Jenkins


    sudo apt update sudo apt install jenkins -y
  4. Start Jenkins


    sudo systemctl start jenkins sudo systemctl enable jenkins
  5. Open in Browser
    Visit http://your-server-ip:8080

    • Unlock Jenkins with password:


      sudo cat /var/lib/jenkins/secrets/initialAdminPassword
    • Install Suggested Plugins

    • Create Admin User


⭐ Most Important Options in Jenkins (For Beginners):

FeatureWhat It Does (In Simple Words)
Freestyle ProjectManually configure tasks like build/test/deploy
PipelineWrite scripts to automate build + deploy
Build TriggersRun job automatically (e.g. when code is pushed)
Source Code Management (SCM)Connect with GitHub, GitLab, Bitbucket
Post-build ActionsSend emails, deploy code, etc. after build
PluginsAdd extra features (GitHub, Docker, Slack, etc.)

Task1 create free style project to print hello world under windows machine

Step1 : Open Jenkins

Step2:   NEW ITEM

Step3    Click on Free Style Project

Step4:  Write Description if required

Step5:  Direct go into build steps

Step6:  Select Windows Batch Command if using Windows or Select Linux command

Step7: Write command  echo HelloWorld

step8: Save

Step9: Click on Build if green then pass of red then fail

Step 10: show console output


Task2:  Create Java Program and push into github using git , compile and execute this code under Jenkins using Free Style Project


Note:  Java Environment Path Must be Set in your PC check from command prompt to write java --version

Step1 : Open Jenkins

Step2:   NEW ITEM

Step3    Click on Free Style Project

Step4:  Write Description if required

Step5: Go into settings --> Manage Jenkins ---> Tools---> Configure Tools--> Set git path

Name: Default
Path    C:\Program Files\Git\bin\git.exe

Step6: Again come on Free Style Project

Step7:  go into source code management and set git public repository path

Step8 Come into Build Step Option and write following command

          echo Java Program compilation
         javac HelloWorld.java
         echo Java Program Execution
        java HelloWorld

step9: Click Build now

step 10: Click on Build and Check Console Output and show Java Code Result


Task3:  Create Python Program and push into github using git ,  execute this code under Jenkins using Free Style Project


Note:  Python Environment Path Must be Set in  System Path and Full path like this (C:\Users\Shiva-PC\AppData\Local\Programs\Python\Python313\) your PC check from command prompt to write python --version

Step1 : Open Jenkins

Step2:   NEW ITEM

Step3    Click on Free Style Project

Step4:  Write Description if required

Step5: Go into settings --> Manage Jenkins ---> Tools---> Configure Tools--> Set git path if it is not 

Name: Default
Path    C:\Program Files\Git\bin\git.exe

Step6: Again come on Free Style Project

Step7:  go into source code management and set git public repository path where python code exist

Step8 Come into Build Step Option and write following command

         python filename

step9: Click Build now

step 10: Click on Build and Check Console Output and show Java Code Result



Task4:  Task3 Build Execute by Github Webhooks


step1st:  Configure build and select Triggers GitHub hook trigger for GITScm polling
?
step2nd: go into github setting ---> Webhooks Option ---->  and try http://localhost:8080/webhooks

step3: it provide error localhost path not supported

step4:  install ngrok to map localpath to remote path

step5th install and dowload ngrok

1. Install ngrok

Download from: https://ngrok.com/download

Extract and place ngrok.exe in a known location (e.g., C:\ngrok\ngrok.exe)

2. Run ngrok to Expose Jenkins

Open Command Prompt and run:


ngrok http 8080

You’ll see output like:


Forwarding http://abc123.ngrok.io -> http://localhost:8080 Forwarding https://abc123.ngrok.io -> http://localhost:8080

✅ Copy the HTTPS URL (e.g., https://abc123.ngrok.io)

3) Manage ngrok authentication with login and authenticate token


step6:  replace ngrok url under payload url like this https://d3d61da557f0.ngrok-free.app/github-webhook/


4) choose webhooks triggers 

i choose commit and push both

5) build automatically created when you push or commit in jenkins









Comments

Popular posts from this blog

Uncontrolled form input in React-JS

  Uncontrolled form input in React-JS? If we want to take input from users without any separate event handling then we can uncontrolled the data binding technique. The uncontrolled input is similar to the traditional HTML form inputs. The DOM itself handles the form data. Here, the HTML elements maintain their own state that will be updated when the input value changes. To write an uncontrolled component, you need to use a ref to get form values from the DOM. In other words, there is no need to write an event handler for every state update. You can use a ref to access the input field value of the form from the DOM. Example of Uncontrolled Form Input:- import React from "react" ; export class Info extends React . Component {     constructor ( props )     {         super ( props );         this . fun = this . fun . bind ( this ); //event method binding         this . input = React . createRef ();...

JSP Page design using Internal CSS

  JSP is used to design the user interface of an application, CSS is used to provide set of properties. Jsp provide proper page template to create user interface of dynamic web application. We can write CSS using three different ways 1)  inline CSS:-   we will write CSS tag under HTML elements <div style="width:200px; height:100px; background-color:green;"></div> 2)  Internal CSS:-  we will write CSS under <style> block. <style type="text/css"> #abc { width:200px;  height:100px;  background-color:green; } </style> <div id="abc"></div> 3) External CSS:-  we will write CSS to create a separate file and link it into HTML Web pages. create a separate file and named it style.css #abc { width:200px;  height:100px;  background-color:green; } go into Jsp page and link style.css <link href="style.css"  type="text/css" rel="stylesheet"   /> <div id="abc"> </div> Exam...

JDBC Database Connectivity using JSP and Servlet, Database connectivity on Java

JDBC Database Connectivity using JSP and Servlet, Database connectivity on Java JDBC:-   JDBC means Java database connectivity, it is used to connect from the front-end(application server) to the back-end(database server) in the case of Java web application. The database provides a set of tables to store records and JDBC will work similarly to the  bridge between the database table and application form. 1)  Class.forName("drivername")  // Manage Drive         Class.formName("com.mysql.jdbc.Driver");  // MYSQL      Class.forName ("oracle.jdbc.driver.OracleDriver"); //Oracle 2)  Manage Connection String     It establish connection from application server to database server, Java provide DriverManage class and getConnection that will return Connection object.    Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/databasename","username","password"); 3)  Manage Statement to...