Forum

Notifications
Clear all

Assignment Task on Jenkins

0
Topic starter

Hi All,

Hope the session went well and you guys were able to understand the basics of Jenkins.

As a hands-on exercise, please complete the following task to solidify your understanding of Jenkins integration with GitHub and setting up pipelines using different scripting languages.


🔧 Assignment Task

Objective:

Create a new Jenkins job (Freestyle or Pipeline) that connects to a GitHub project, triggers a build using a webhook on every commit, and runs a scripted pipeline using a language of your choice.


📌 Instructions:

  1. GitHub Project Setup

    • Create a simple GitHub repository with a basic application/script using any one of the following languages:

      • Shell script (bash)

      • Python

      • Node.js

      • Java (Maven or Gradle)

      • Go

  2. Add a Sample Script/File

    • Include a basic script such as:

      • A Python script that prints "Hello from Jenkins!"

      • A Shell script that lists directory contents

      • A simple Node.js/Java/Go program with a basic function

  3. Create Jenkins Job

    • Create a new item in Jenkins (Freestyle or Pipeline).

    • Connect it to your GitHub repository using Git.

    • Enable webhook-based triggering by:

  4. Pipeline Script

    • Write a Jenkinsfile (for Pipeline jobs) or use “Execute shell” (for Freestyle) to run your script.

    • Example (for Python):

      pipeline {
      agent any
      stages {
      stage('Clone Repo') {
      steps {
      git 'https://github.com/your-username/your-repo.git'
      }
      }
      stage('Run Script') {
      steps {
      sh 'python3 your_script.py'
      }
      }
      }
      }

       

5. Validation

  • Push a commit to your GitHub repo and ensure Jenkins triggers the job automatically.

  • The build should execute and print the output of your script.

 

 

 

 

 

 

 

 

 

© Copyright 2024, All rights reserved by HeyCloud Innovations LLP | designed by ColorWhistle | Privacy Policy | Terms and Conditions