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:
-
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
-
-
-
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
-
-
-
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:
-
Adding the GitHub webhook to your repo (
http://<your_jenkins_url>/github-webhook/
) -
Configuring Jenkins to trigger build on GitHub push
-
-
-
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.