Part 7: Control Jenkins Pipeline through GitHub
Jenkins Pipeline from GitHub

Jenkins CI/CD Series
Goal
Configure Jenkins to use a Jenkinsfile stored in a GitHub repository, enabling pipelines to be version-controlled, automatically updated, and executed directly from source code.
Purpose
The purpose of this part is to introduce Pipeline as Code using GitHub, which is a core DevOps practice.
By the end of this setup, you will:
Store Jenkins pipeline logic inside GitHub
Configure Jenkins to pull pipeline code from SCM
Automatically detect changes in the repository
Build pipelines that are version-controlled and reusable
This approach ensures that your CI/CD pipelines are:
Traceable (tracked via Git commits)
Collaborative (teams can contribute)
Consistent (same pipeline across environments)
Prerequisites
Before starting this part, ensure you have:
Ready to use
Hostand thedirectorystructure to runDockerfilesanddocker-compose.yml(Refer to Part 1)A GitHub account
Access to a demo-app repository (fork or create)
Step-by-step implementation
- Jenkinsfile is placed at the location below in the repo, and will be used
- Create a new Job
maven-github-pipeline
- Select options as below
Definition: Pipeline script from SCM
SCM: Git
Repository URL : Forked repo HTTP URL
Branch Specifier (blank for 'any'): */main
Script Path: jenkins/Jenkinsfile
Build now
- Go through the console output logs
- Build now one more time, and go to Jobs Console output and compare
This is not cloning the repo again; instead, it's checking if there are any latest commits and changes
Done!!!
Conclusion
In this part, you successfully moved your Jenkins pipeline to GitHub, adopting the powerful concept of Pipeline as Code.
You have:
Connected Jenkins to a GitHub repository
Configured pipeline jobs to fetch the Jenkinsfile from SCM
Executed builds directly from the repository code
Observed how Jenkins detects changes without re-cloning
Introduced version-controlled CI/CD workflows
This is a critical step toward modern DevOps practices, where pipelines are no longer managed manually in Jenkins but are fully integrated with source control systems.
With this setup, your pipeline becomes:
Scalable
Maintainable
Production-ready
🔗 Continue the Series
⬅️ Previous Article: Part 6 Running Ansible from Jenkins
➡️ Next Article: Part 8 Multibranch Pipelines
⭐ If you found this article useful, follow https://ask-abhi.com for more DevOps tutorials.





