SlideShare a Scribd company logo
1 of 9
Download to read offline
Continuous Integration using Jenkins with
Python
Continuous Integration (CI) has changed how we create and deliver software, making
it quicker, more efficient, and reducing mistakes. Jenkins, a well-known free tool, is
crucial for CI because it automates different parts of building software.
In this blog, we will take a gander at how Jenkins functions impeccably with Python,
a famous programming language. We will go through how to set up Jenkins for
Python projects, how to configure it, and how to run these projects. This shows how
utilizing Jenkins with the Python Development process smoother, increases work
efficiency, and keeps the quality of software consistent. This post is useful for
everybody, from experienced designers to those simply beginning with CI, offering
helpful hints on capitalizing on Jenkins and Python in your CI process.
What is Jenkins?
Jenkins is an open-source automation server that enables developers to integrate,
test, and deploy code changes seamlessly. It facilitates continuous integration and
continuous delivery (CI/CD) practices, ensuring that software applications are built,
tested, and released in a timely and efficient manner.
Prerequisites of integrating Jenkins with Python
Before diving into integrating Jenkins with Python, there are a few key things you’ll
need.
Basic Understanding of Python Programming: You should be comfortable with
writing and understanding Python code. This knowledge is crucial since we’ll be
working with Python projects.
Familiarity with Git Version Control System: Knowing how to use Git is important
because Jenkins often interacts with repositories for CI processes.
Essential Requirements
In addition to the basic knowledge, there are some essential tools and setups you
need:
Jenkins Installation and Configuration: You should have Jenkins installed and
properly configured on your machine or a cloud platform. This is the backbone of the
CI process we’re discussing.
Python Development Environment Setup: Your machine should be set up for Python
development, including having Python installed along with any necessary libraries
and development tools.
With these prerequisites and essentials in place, you’ll be well-prepared to start
integrating Jenkins with your Python projects.
Also Learn: Python Environment Variables
Core Functionality of Jenkins
Continuous Integration (CI): Jenkins monitors source code repositories like Git or
SVN for code changes. Whenever a change is detected, it automatically triggers a
build process, which involves compiling, testing, and analyzing the code. This ensures
that the codebase remains stable and free of errors.
Continuous Delivery (CD): Once the build process is complete and the code is
deemed stable, Jenkins can automatically deploy the updated code to production
environments. This eliminates the need for manual deployment tasks, reducing the
time it takes to release new features and bug fixes.
Pipelines: Jenkins utilizes pipelines to define and execute automated workflows for
building, testing, and deploying code. Pipelines are composed of stages, each
representing a specific step in the workflow. This allows for granular control over the
automation process.
Plugins: Jenkins boasts a vast ecosystem of plugins that extend its functionality and
integrations with various tools and platforms. Plugins provide a wide range of
capabilities, such as code analysis, reporting, and integration with different cloud
providers.
Benefits of Using Jenkins
Improved Code Quality: Jenkins automates testing, enabling early detection of bugs
and ensuring code quality throughout the development cycle.
Faster Release Cycles: Automated builds and deployments significantly reduce the
time it takes to release new features and updates.
Reduced Errors: Automation minimizes human error and ensures consistency in the
build, test, and deployment process.
Scalability: Jenkins can handle complex workflows and manage multiple builds
simultaneously, making it suitable for large-scale projects.
Cost-Effectiveness: Automation frees up developers’ time, allowing them to focus on
core development tasks and reducing overall development costs.
Let’s get started by creating a simple fast API application that sends data to a
RabbitMQ queue, and the consumer consumes the data from the queue.
Here’s the link to set up RabbitMQ in Ubuntu
22.04
https://vegastack.com/tutorials/how-to-install-rabbitmq-on-ubuntu-22-04/
Let’s set up the repository in the local. The steps to set up are as follows.
1. Clone the repository from the URL mentioned
https://github.com/shubhamsinha1010/jenkin-learning.git
2. After that create virtualenv in your system by using the following command
virtualenv venv
source venv bin/activate
I have named the virtualenv as venv, we can use any name as per our choice.
3. after that, let’s install the requirements using the command
pip install –r requirements.txt
uvicorn main:app
Now we have a fast API application up and running
Also Learn: Jaeger Integration with Spring Cloud
Let’s integrate Jenkins into our fast API
application
Jenkins requires Java to run. Ensure you have Java installed on your system
sudo apt update
sudo apt install default-jre
Add the Jenkins repository key to your system and install Jenkins
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 update
sudo apt install Jenkins
Once installed, start and enable the Jenkins service
sudo systemctl start Jenkins
sudo systemctl enable Jenkins
Jenkins usually runs on port 8080 by default. Open a web browser and navigate to
http://localhost:8080 or http://your_server_ip:8080 to access the Jenkins
dashboard.
Follow the setup wizard in the browser to complete the installation. You’ll need to
retrieve the initial admin password, which can be found in the Jenkins server logs:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Go to Jenkins Dashboard -> Manage Jenkins -> Manage Plugins -> Available. Look
for plugins related to Python, such as “Python Plugin” or “Pipeline Utility Steps”,
and install them.
Now, to create a new job, follow the below steps
Step 1: Create a new job
In Jenkins, go to Manage Jenkins > New Item.
Select Pipeline from the Job Type drop-down menu.
Enter a name for your job, such as “MyPipelineJob”.
Click OK to create the job.
Step 2: Configure the Git repository
On the job configuration page, go to the Source Code Management section.
Select Git from the SCM drop-down menu.
Enter the URL of your git repository in the Repository URL field.
If your repository requires authentication, click the Credentials button and select the
appropriate credentials from the list.
Click Save to save the configuration.
Step 3: Define the pipeline script
On the job configuration page, go to the Pipeline Scripts section.
Select Pipeline script from SCM from the Pipeline Source drop-down menu.
Enter the name of the pipeline script file in the Pipeline script path field. For
example, if your pipeline script is named pipeline.groovy, enter pipeline.groovy.
Click Save to save the configuration.
Step 4: Trigger the pipeline on commits
On the job configuration page, go to the Build Triggers section.
Select Poll SCM from the Build Triggers drop-down menu.
Enter a value for the Poll SCM frequency field. This value determines how often
Jenkins will poll your git repository for changes. For example, if you enter *** * * *
***, Jenkins will poll your repository every minute.
Click Save to save the configuration.
Changes to be made in the Jenkins settings
The following changes should be made in the Jenkins settings
Create a new job: This job will be responsible for running the pipeline whenever a
code is committed in a particular Git repository.
Configure the Git repository: This step specifies the URL of the Git repository that
you want to monitor for changes.
Define the pipeline script: This step specifies the location of the pipeline script file
that contains the code for your pipeline.
Trigger the pipeline on commits: This step tells Jenkins to poll your git repository for
changes and run the pipeline whenever a new commit is detected.
Additional notes:
You can also use the Build with Parameters option to allow users to pass parameters
to the pipeline when it is triggered.
You can use the Build Authorization option to restrict who can trigger the pipeline.
You can use the Notifications option to configure notifications for pipeline events,
such as builds starting and completing.
Let’s configure the webhook in GitHub
Configuring the GitHub repository:
Access repository settings: Navigate to the GitHub repository where you want to
enable webhooks. Click on the repository name, then select “Settings” from the
dropdown menu.
Enable webhooks: In the settings sidebar, locate the “Integrations” section and click
on “Webhook”.
Create a new webhook: Click on the “Add webhook” button.
Provide webhook URL: In the “Payload URL” field, enter the URL of your Jenkins job.
This URL will be used to deliver notifications about code changes.
Select content type: Choose the content type for the webhook payload. The
preferred option is “application/json”, which sends the payload directly as a JSON
object in the POST request.
Optional: Configure webhook secret: For added security, you can set a webhook
secret. This secret will be used to verify the authenticity of incoming requests from
GitHub.
Select events to trigger webhook: Choose the events that should trigger the
webhook. Common options include “push” (for code pushes), “pull_request” (for pull
requests), and “delete” (for deleting branches or tags).
Click “Add webhook” to save: Once you’ve configured the webhook settings, click on
the “Add webhook” button to save the changes.
Now, it is time to configure Slack with Jenkins which sends a Slack notification
whenever a Jenkins job starts, succeeds, or fails
Create a Slack App: In your Slack workspace, navigate to the “Apps” page. Click on
the “Create New App” button and select “From Scratch”.
Name your Slack App: Enter a name for your Slack app, such as “Jenkins
Notifications”.
Choose app type: Select “Incoming Webhooks” as the app type. This will allow your
Jenkins job to send notifications to Slack channels.
Add bot user: Click on the “Add bot user” button. This will create a bot user for your
Slack app, which will be used to send notifications.
Copy webhook URL: Note down the webhook URL provided by Slack. This URL will be
used in the Jenkins job configuration.
Install Slack app: Click on the “Install to Slack” button and follow the prompts to
install the Slack app in your workspace.
Configuring Jenkins:
Install Slack Plugin: In Jenkins, go to Manage Jenkins > Plugins. Search for the “Slack
Plugin” and install it.
Configure Slack Global Settings: In Jenkins, go to Manage Jenkins > Configure
System. Under the “Slack” section, enter the following information:
Slack Webhook URL: Paste the webhook URL you copied from Slack.
Default Channel: Specify the default Slack channel where notifications should be
sent. You can override this channel for specific jobs.
Configure Slack Notifications for a Job: Open the job configuration page for the job
you want to receive Slack notifications for.
Slack Notifications: Under the “Post-build Actions” section, select “Slack
Notification”.
Channel: Choose the Slack channel where notifications should be sent for this job.
You can also use a custom channel syntax like #my-custom-channel.
Condition: Select the events for which you want to send Slack notifications. Options
include “Always”, “Success”, “Failure”, “Unstable”, and “Not Built”.
Message: Customize the message that will be sent to Slack. You can use variables like
${JOB_NAME}, ${BUILD_STATUS}, and ${BUILD_URL} to insert job-specific
information.
Save Jenkins Job Configuration: Click on the “Save” button to apply the Slack
notification settings for the job.
Now, whenever your Jenkins job starts, succeeds, or fails, a Slack notification will be
sent to the specified channel, providing you with real-time updates on your build
status.
So now, we have a CI-ready Fastapi web application using Jenkins, slack, and GitHub
webhooks.
To sum it up, using Jenkins with Python for Continuous Integration can really change
the way you develop software. It not only makes things faster but also helps in
reducing mistakes, leading to a more efficient and smooth workflow. Automating
various steps, like testing and deploying your software, is key to making sure it’s of
good quality.
With Jenkins and Python together, developers can create software that’s both
trustworthy and strong. Plus, Jenkins has a lot of extra tools and resources that can
make your Continuous Integration process even better. It’s a tool that can grow with
your needs in today’s software development world. So, I suggest exploring these
tools and resources to make the most out of Jenkins in your Python projects and see
how far you can go with Continuous Integration.
Also Learn: How to Integrate Apache Kafka with Spring Boot
Originally published by: Continuous Integration using Jenkins with Python

More Related Content

Similar to Continuous Integration using Jenkins with Python

CI/CD with Jenkins and Docker - DevOps Meetup Day Thailand
CI/CD with Jenkins and Docker - DevOps Meetup Day ThailandCI/CD with Jenkins and Docker - DevOps Meetup Day Thailand
CI/CD with Jenkins and Docker - DevOps Meetup Day ThailandTroublemaker Khunpech
 
Jenkins workflows and Best Practices
Jenkins workflows and Best PracticesJenkins workflows and Best Practices
Jenkins workflows and Best PracticesKenichi Shibata
 
DevOps & DevEx
DevOps & DevExDevOps & DevEx
DevOps & DevExIfunga Ndana
 
When to use Serverless? When to use Kubernetes?
When to use Serverless? When to use Kubernetes?When to use Serverless? When to use Kubernetes?
When to use Serverless? When to use Kubernetes?Niklas Heidloff
 
[Devopsdays2021] Roll Your Product with Kaizen Culture
[Devopsdays2021] Roll Your Product with Kaizen Culture[Devopsdays2021] Roll Your Product with Kaizen Culture
[Devopsdays2021] Roll Your Product with Kaizen CultureWoohyeok Kim
 
UGent Django Infrastructure
UGent Django InfrastructureUGent Django Infrastructure
UGent Django Infrastructurekevinvw
 
POST/CON 2019 Workshop: Testing, Automated Testing, and Reporting APIs with P...
POST/CON 2019 Workshop: Testing, Automated Testing, and Reporting APIs with P...POST/CON 2019 Workshop: Testing, Automated Testing, and Reporting APIs with P...
POST/CON 2019 Workshop: Testing, Automated Testing, and Reporting APIs with P...Postman
 
Continuous Integration using Cruise Control
Continuous Integration using Cruise ControlContinuous Integration using Cruise Control
Continuous Integration using Cruise Controlelliando dias
 
Simple tools to fight bigger quality battle
Simple tools to fight bigger quality battleSimple tools to fight bigger quality battle
Simple tools to fight bigger quality battleAnand Ramdeo
 
Exercising and Scaling Up Mobile DevOps in the Enterprise
Exercising and Scaling Up Mobile DevOps in the EnterpriseExercising and Scaling Up Mobile DevOps in the Enterprise
Exercising and Scaling Up Mobile DevOps in the EnterpriseBitbar
 
Nagpur Mulesoft Meetup on CICD using Jenkins
Nagpur Mulesoft Meetup on CICD using JenkinsNagpur Mulesoft Meetup on CICD using Jenkins
Nagpur Mulesoft Meetup on CICD using Jenkinspqrs1234
 

Similar to Continuous Integration using Jenkins with Python (20)

jenkins.pdf
jenkins.pdfjenkins.pdf
jenkins.pdf
 
Build Time Hacking
Build Time HackingBuild Time Hacking
Build Time Hacking
 
CI/CD with Jenkins and Docker - DevOps Meetup Day Thailand
CI/CD with Jenkins and Docker - DevOps Meetup Day ThailandCI/CD with Jenkins and Docker - DevOps Meetup Day Thailand
CI/CD with Jenkins and Docker - DevOps Meetup Day Thailand
 
Jenkins workflows and Best Practices
Jenkins workflows and Best PracticesJenkins workflows and Best Practices
Jenkins workflows and Best Practices
 
DevOps & DevEx
DevOps & DevExDevOps & DevEx
DevOps & DevEx
 
Jenkins pipeline as code
Jenkins pipeline as codeJenkins pipeline as code
Jenkins pipeline as code
 
When to use Serverless? When to use Kubernetes?
When to use Serverless? When to use Kubernetes?When to use Serverless? When to use Kubernetes?
When to use Serverless? When to use Kubernetes?
 
[Devopsdays2021] Roll Your Product with Kaizen Culture
[Devopsdays2021] Roll Your Product with Kaizen Culture[Devopsdays2021] Roll Your Product with Kaizen Culture
[Devopsdays2021] Roll Your Product with Kaizen Culture
 
UGent Django Infrastructure
UGent Django InfrastructureUGent Django Infrastructure
UGent Django Infrastructure
 
Dev ops for rpa
Dev ops for rpaDev ops for rpa
Dev ops for rpa
 
AWS Code Services
AWS Code ServicesAWS Code Services
AWS Code Services
 
POST/CON 2019 Workshop: Testing, Automated Testing, and Reporting APIs with P...
POST/CON 2019 Workshop: Testing, Automated Testing, and Reporting APIs with P...POST/CON 2019 Workshop: Testing, Automated Testing, and Reporting APIs with P...
POST/CON 2019 Workshop: Testing, Automated Testing, and Reporting APIs with P...
 
Continuous Integration using Cruise Control
Continuous Integration using Cruise ControlContinuous Integration using Cruise Control
Continuous Integration using Cruise Control
 
Simple tools to fight bigger quality battle
Simple tools to fight bigger quality battleSimple tools to fight bigger quality battle
Simple tools to fight bigger quality battle
 
Dev ops using Jenkins
Dev ops using JenkinsDev ops using Jenkins
Dev ops using Jenkins
 
Exercising and Scaling Up Mobile DevOps in the Enterprise
Exercising and Scaling Up Mobile DevOps in the EnterpriseExercising and Scaling Up Mobile DevOps in the Enterprise
Exercising and Scaling Up Mobile DevOps in the Enterprise
 
Jenkins
JenkinsJenkins
Jenkins
 
Nagpur Mulesoft Meetup on CICD using Jenkins
Nagpur Mulesoft Meetup on CICD using JenkinsNagpur Mulesoft Meetup on CICD using Jenkins
Nagpur Mulesoft Meetup on CICD using Jenkins
 
Dev Ops
Dev OpsDev Ops
Dev Ops
 
Jenkins-CI
Jenkins-CIJenkins-CI
Jenkins-CI
 

More from Inexture Solutions

Spring Boot for WebRTC Signaling Servers: A Comprehensive Guide
Spring Boot for WebRTC Signaling Servers: A Comprehensive GuideSpring Boot for WebRTC Signaling Servers: A Comprehensive Guide
Spring Boot for WebRTC Signaling Servers: A Comprehensive GuideInexture Solutions
 
Mobile App Development Cost 2024 Budgeting Your Dream App
Mobile App Development Cost 2024 Budgeting Your Dream AppMobile App Development Cost 2024 Budgeting Your Dream App
Mobile App Development Cost 2024 Budgeting Your Dream AppInexture Solutions
 
Data Serialization in Python JSON vs. Pickle
Data Serialization in Python JSON vs. PickleData Serialization in Python JSON vs. Pickle
Data Serialization in Python JSON vs. PickleInexture Solutions
 
Best EV Charging App 2024 A Tutorial on Building Your Own
Best EV Charging App 2024 A Tutorial on Building Your OwnBest EV Charging App 2024 A Tutorial on Building Your Own
Best EV Charging App 2024 A Tutorial on Building Your OwnInexture Solutions
 
What is a WebSocket? Real-Time Communication in Applications
What is a WebSocket? Real-Time Communication in ApplicationsWhat is a WebSocket? Real-Time Communication in Applications
What is a WebSocket? Real-Time Communication in ApplicationsInexture Solutions
 
SaaS Application Development Explained in 10 mins
SaaS Application Development Explained in 10 minsSaaS Application Development Explained in 10 mins
SaaS Application Development Explained in 10 minsInexture Solutions
 
Best 7 SharePoint Migration Tools of 2024
Best 7 SharePoint Migration Tools of 2024Best 7 SharePoint Migration Tools of 2024
Best 7 SharePoint Migration Tools of 2024Inexture Solutions
 
Spring Boot with Microsoft Azure Integration.pdf
Spring Boot with Microsoft Azure Integration.pdfSpring Boot with Microsoft Azure Integration.pdf
Spring Boot with Microsoft Azure Integration.pdfInexture Solutions
 
Best Features of Adobe Experience Manager (AEM).pdf
Best Features of Adobe Experience Manager (AEM).pdfBest Features of Adobe Experience Manager (AEM).pdf
Best Features of Adobe Experience Manager (AEM).pdfInexture Solutions
 
React Router Dom Integration Tutorial for Developers
React Router Dom Integration Tutorial for DevelopersReact Router Dom Integration Tutorial for Developers
React Router Dom Integration Tutorial for DevelopersInexture Solutions
 
Python Kafka Integration: Developers Guide
Python Kafka Integration: Developers GuidePython Kafka Integration: Developers Guide
Python Kafka Integration: Developers GuideInexture Solutions
 
What is SaMD Model, Benefits, and Development Process.pdf
What is SaMD Model, Benefits, and Development Process.pdfWhat is SaMD Model, Benefits, and Development Process.pdf
What is SaMD Model, Benefits, and Development Process.pdfInexture Solutions
 
Unlocking the Potential of AI in Spring.pdf
Unlocking the Potential of AI in Spring.pdfUnlocking the Potential of AI in Spring.pdf
Unlocking the Potential of AI in Spring.pdfInexture Solutions
 
Mobile Banking App Development Cost in 2024.pdf
Mobile Banking App Development Cost in 2024.pdfMobile Banking App Development Cost in 2024.pdf
Mobile Banking App Development Cost in 2024.pdfInexture Solutions
 
Education App Development : Cost, Features and Example
Education App Development : Cost, Features and ExampleEducation App Development : Cost, Features and Example
Education App Development : Cost, Features and ExampleInexture Solutions
 
Firebase Push Notification in JavaScript Apps
Firebase Push Notification in JavaScript AppsFirebase Push Notification in JavaScript Apps
Firebase Push Notification in JavaScript AppsInexture Solutions
 
Micronaut Framework Guide Framework Basics and Fundamentals.pdf
Micronaut Framework Guide Framework Basics and Fundamentals.pdfMicronaut Framework Guide Framework Basics and Fundamentals.pdf
Micronaut Framework Guide Framework Basics and Fundamentals.pdfInexture Solutions
 
Steps to Install NPM and Node.js on Windows and MAC
Steps to Install NPM and Node.js on Windows and MACSteps to Install NPM and Node.js on Windows and MAC
Steps to Install NPM and Node.js on Windows and MACInexture Solutions
 
Python Requirements File How to Create Python requirements.txt
Python Requirements File How to Create Python requirements.txtPython Requirements File How to Create Python requirements.txt
Python Requirements File How to Create Python requirements.txtInexture Solutions
 
Gain Proficiency in Batch Processing with Spring Batch
Gain Proficiency in Batch Processing with Spring BatchGain Proficiency in Batch Processing with Spring Batch
Gain Proficiency in Batch Processing with Spring BatchInexture Solutions
 

More from Inexture Solutions (20)

Spring Boot for WebRTC Signaling Servers: A Comprehensive Guide
Spring Boot for WebRTC Signaling Servers: A Comprehensive GuideSpring Boot for WebRTC Signaling Servers: A Comprehensive Guide
Spring Boot for WebRTC Signaling Servers: A Comprehensive Guide
 
Mobile App Development Cost 2024 Budgeting Your Dream App
Mobile App Development Cost 2024 Budgeting Your Dream AppMobile App Development Cost 2024 Budgeting Your Dream App
Mobile App Development Cost 2024 Budgeting Your Dream App
 
Data Serialization in Python JSON vs. Pickle
Data Serialization in Python JSON vs. PickleData Serialization in Python JSON vs. Pickle
Data Serialization in Python JSON vs. Pickle
 
Best EV Charging App 2024 A Tutorial on Building Your Own
Best EV Charging App 2024 A Tutorial on Building Your OwnBest EV Charging App 2024 A Tutorial on Building Your Own
Best EV Charging App 2024 A Tutorial on Building Your Own
 
What is a WebSocket? Real-Time Communication in Applications
What is a WebSocket? Real-Time Communication in ApplicationsWhat is a WebSocket? Real-Time Communication in Applications
What is a WebSocket? Real-Time Communication in Applications
 
SaaS Application Development Explained in 10 mins
SaaS Application Development Explained in 10 minsSaaS Application Development Explained in 10 mins
SaaS Application Development Explained in 10 mins
 
Best 7 SharePoint Migration Tools of 2024
Best 7 SharePoint Migration Tools of 2024Best 7 SharePoint Migration Tools of 2024
Best 7 SharePoint Migration Tools of 2024
 
Spring Boot with Microsoft Azure Integration.pdf
Spring Boot with Microsoft Azure Integration.pdfSpring Boot with Microsoft Azure Integration.pdf
Spring Boot with Microsoft Azure Integration.pdf
 
Best Features of Adobe Experience Manager (AEM).pdf
Best Features of Adobe Experience Manager (AEM).pdfBest Features of Adobe Experience Manager (AEM).pdf
Best Features of Adobe Experience Manager (AEM).pdf
 
React Router Dom Integration Tutorial for Developers
React Router Dom Integration Tutorial for DevelopersReact Router Dom Integration Tutorial for Developers
React Router Dom Integration Tutorial for Developers
 
Python Kafka Integration: Developers Guide
Python Kafka Integration: Developers GuidePython Kafka Integration: Developers Guide
Python Kafka Integration: Developers Guide
 
What is SaMD Model, Benefits, and Development Process.pdf
What is SaMD Model, Benefits, and Development Process.pdfWhat is SaMD Model, Benefits, and Development Process.pdf
What is SaMD Model, Benefits, and Development Process.pdf
 
Unlocking the Potential of AI in Spring.pdf
Unlocking the Potential of AI in Spring.pdfUnlocking the Potential of AI in Spring.pdf
Unlocking the Potential of AI in Spring.pdf
 
Mobile Banking App Development Cost in 2024.pdf
Mobile Banking App Development Cost in 2024.pdfMobile Banking App Development Cost in 2024.pdf
Mobile Banking App Development Cost in 2024.pdf
 
Education App Development : Cost, Features and Example
Education App Development : Cost, Features and ExampleEducation App Development : Cost, Features and Example
Education App Development : Cost, Features and Example
 
Firebase Push Notification in JavaScript Apps
Firebase Push Notification in JavaScript AppsFirebase Push Notification in JavaScript Apps
Firebase Push Notification in JavaScript Apps
 
Micronaut Framework Guide Framework Basics and Fundamentals.pdf
Micronaut Framework Guide Framework Basics and Fundamentals.pdfMicronaut Framework Guide Framework Basics and Fundamentals.pdf
Micronaut Framework Guide Framework Basics and Fundamentals.pdf
 
Steps to Install NPM and Node.js on Windows and MAC
Steps to Install NPM and Node.js on Windows and MACSteps to Install NPM and Node.js on Windows and MAC
Steps to Install NPM and Node.js on Windows and MAC
 
Python Requirements File How to Create Python requirements.txt
Python Requirements File How to Create Python requirements.txtPython Requirements File How to Create Python requirements.txt
Python Requirements File How to Create Python requirements.txt
 
Gain Proficiency in Batch Processing with Spring Batch
Gain Proficiency in Batch Processing with Spring BatchGain Proficiency in Batch Processing with Spring Batch
Gain Proficiency in Batch Processing with Spring Batch
 

Recently uploaded

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 

Recently uploaded (20)

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 

Continuous Integration using Jenkins with Python

  • 1. Continuous Integration using Jenkins with Python Continuous Integration (CI) has changed how we create and deliver software, making it quicker, more efficient, and reducing mistakes. Jenkins, a well-known free tool, is crucial for CI because it automates different parts of building software. In this blog, we will take a gander at how Jenkins functions impeccably with Python, a famous programming language. We will go through how to set up Jenkins for Python projects, how to configure it, and how to run these projects. This shows how utilizing Jenkins with the Python Development process smoother, increases work efficiency, and keeps the quality of software consistent. This post is useful for everybody, from experienced designers to those simply beginning with CI, offering helpful hints on capitalizing on Jenkins and Python in your CI process. What is Jenkins? Jenkins is an open-source automation server that enables developers to integrate, test, and deploy code changes seamlessly. It facilitates continuous integration and
  • 2. continuous delivery (CI/CD) practices, ensuring that software applications are built, tested, and released in a timely and efficient manner. Prerequisites of integrating Jenkins with Python Before diving into integrating Jenkins with Python, there are a few key things you’ll need. Basic Understanding of Python Programming: You should be comfortable with writing and understanding Python code. This knowledge is crucial since we’ll be working with Python projects. Familiarity with Git Version Control System: Knowing how to use Git is important because Jenkins often interacts with repositories for CI processes. Essential Requirements In addition to the basic knowledge, there are some essential tools and setups you need: Jenkins Installation and Configuration: You should have Jenkins installed and properly configured on your machine or a cloud platform. This is the backbone of the CI process we’re discussing. Python Development Environment Setup: Your machine should be set up for Python development, including having Python installed along with any necessary libraries and development tools. With these prerequisites and essentials in place, you’ll be well-prepared to start integrating Jenkins with your Python projects. Also Learn: Python Environment Variables Core Functionality of Jenkins Continuous Integration (CI): Jenkins monitors source code repositories like Git or SVN for code changes. Whenever a change is detected, it automatically triggers a
  • 3. build process, which involves compiling, testing, and analyzing the code. This ensures that the codebase remains stable and free of errors. Continuous Delivery (CD): Once the build process is complete and the code is deemed stable, Jenkins can automatically deploy the updated code to production environments. This eliminates the need for manual deployment tasks, reducing the time it takes to release new features and bug fixes. Pipelines: Jenkins utilizes pipelines to define and execute automated workflows for building, testing, and deploying code. Pipelines are composed of stages, each representing a specific step in the workflow. This allows for granular control over the automation process. Plugins: Jenkins boasts a vast ecosystem of plugins that extend its functionality and integrations with various tools and platforms. Plugins provide a wide range of capabilities, such as code analysis, reporting, and integration with different cloud providers. Benefits of Using Jenkins Improved Code Quality: Jenkins automates testing, enabling early detection of bugs and ensuring code quality throughout the development cycle. Faster Release Cycles: Automated builds and deployments significantly reduce the time it takes to release new features and updates. Reduced Errors: Automation minimizes human error and ensures consistency in the build, test, and deployment process. Scalability: Jenkins can handle complex workflows and manage multiple builds simultaneously, making it suitable for large-scale projects. Cost-Effectiveness: Automation frees up developers’ time, allowing them to focus on core development tasks and reducing overall development costs. Let’s get started by creating a simple fast API application that sends data to a RabbitMQ queue, and the consumer consumes the data from the queue.
  • 4. Here’s the link to set up RabbitMQ in Ubuntu 22.04 https://vegastack.com/tutorials/how-to-install-rabbitmq-on-ubuntu-22-04/ Let’s set up the repository in the local. The steps to set up are as follows. 1. Clone the repository from the URL mentioned https://github.com/shubhamsinha1010/jenkin-learning.git 2. After that create virtualenv in your system by using the following command virtualenv venv source venv bin/activate I have named the virtualenv as venv, we can use any name as per our choice. 3. after that, let’s install the requirements using the command pip install –r requirements.txt uvicorn main:app Now we have a fast API application up and running Also Learn: Jaeger Integration with Spring Cloud Let’s integrate Jenkins into our fast API application Jenkins requires Java to run. Ensure you have Java installed on your system sudo apt update sudo apt install default-jre Add the Jenkins repository key to your system and install Jenkins 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 update sudo apt install Jenkins
  • 5. Once installed, start and enable the Jenkins service sudo systemctl start Jenkins sudo systemctl enable Jenkins Jenkins usually runs on port 8080 by default. Open a web browser and navigate to http://localhost:8080 or http://your_server_ip:8080 to access the Jenkins dashboard. Follow the setup wizard in the browser to complete the installation. You’ll need to retrieve the initial admin password, which can be found in the Jenkins server logs: sudo cat /var/lib/jenkins/secrets/initialAdminPassword Go to Jenkins Dashboard -> Manage Jenkins -> Manage Plugins -> Available. Look for plugins related to Python, such as “Python Plugin” or “Pipeline Utility Steps”, and install them. Now, to create a new job, follow the below steps Step 1: Create a new job In Jenkins, go to Manage Jenkins > New Item. Select Pipeline from the Job Type drop-down menu. Enter a name for your job, such as “MyPipelineJob”. Click OK to create the job. Step 2: Configure the Git repository On the job configuration page, go to the Source Code Management section. Select Git from the SCM drop-down menu. Enter the URL of your git repository in the Repository URL field. If your repository requires authentication, click the Credentials button and select the appropriate credentials from the list. Click Save to save the configuration. Step 3: Define the pipeline script On the job configuration page, go to the Pipeline Scripts section. Select Pipeline script from SCM from the Pipeline Source drop-down menu.
  • 6. Enter the name of the pipeline script file in the Pipeline script path field. For example, if your pipeline script is named pipeline.groovy, enter pipeline.groovy. Click Save to save the configuration. Step 4: Trigger the pipeline on commits On the job configuration page, go to the Build Triggers section. Select Poll SCM from the Build Triggers drop-down menu. Enter a value for the Poll SCM frequency field. This value determines how often Jenkins will poll your git repository for changes. For example, if you enter *** * * * ***, Jenkins will poll your repository every minute. Click Save to save the configuration. Changes to be made in the Jenkins settings The following changes should be made in the Jenkins settings Create a new job: This job will be responsible for running the pipeline whenever a code is committed in a particular Git repository. Configure the Git repository: This step specifies the URL of the Git repository that you want to monitor for changes. Define the pipeline script: This step specifies the location of the pipeline script file that contains the code for your pipeline. Trigger the pipeline on commits: This step tells Jenkins to poll your git repository for changes and run the pipeline whenever a new commit is detected. Additional notes: You can also use the Build with Parameters option to allow users to pass parameters to the pipeline when it is triggered. You can use the Build Authorization option to restrict who can trigger the pipeline. You can use the Notifications option to configure notifications for pipeline events, such as builds starting and completing.
  • 7. Let’s configure the webhook in GitHub Configuring the GitHub repository: Access repository settings: Navigate to the GitHub repository where you want to enable webhooks. Click on the repository name, then select “Settings” from the dropdown menu. Enable webhooks: In the settings sidebar, locate the “Integrations” section and click on “Webhook”. Create a new webhook: Click on the “Add webhook” button. Provide webhook URL: In the “Payload URL” field, enter the URL of your Jenkins job. This URL will be used to deliver notifications about code changes. Select content type: Choose the content type for the webhook payload. The preferred option is “application/json”, which sends the payload directly as a JSON object in the POST request. Optional: Configure webhook secret: For added security, you can set a webhook secret. This secret will be used to verify the authenticity of incoming requests from GitHub. Select events to trigger webhook: Choose the events that should trigger the webhook. Common options include “push” (for code pushes), “pull_request” (for pull requests), and “delete” (for deleting branches or tags). Click “Add webhook” to save: Once you’ve configured the webhook settings, click on the “Add webhook” button to save the changes. Now, it is time to configure Slack with Jenkins which sends a Slack notification whenever a Jenkins job starts, succeeds, or fails Create a Slack App: In your Slack workspace, navigate to the “Apps” page. Click on the “Create New App” button and select “From Scratch”. Name your Slack App: Enter a name for your Slack app, such as “Jenkins Notifications”. Choose app type: Select “Incoming Webhooks” as the app type. This will allow your Jenkins job to send notifications to Slack channels. Add bot user: Click on the “Add bot user” button. This will create a bot user for your Slack app, which will be used to send notifications. Copy webhook URL: Note down the webhook URL provided by Slack. This URL will be used in the Jenkins job configuration. Install Slack app: Click on the “Install to Slack” button and follow the prompts to install the Slack app in your workspace.
  • 8. Configuring Jenkins: Install Slack Plugin: In Jenkins, go to Manage Jenkins > Plugins. Search for the “Slack Plugin” and install it. Configure Slack Global Settings: In Jenkins, go to Manage Jenkins > Configure System. Under the “Slack” section, enter the following information: Slack Webhook URL: Paste the webhook URL you copied from Slack. Default Channel: Specify the default Slack channel where notifications should be sent. You can override this channel for specific jobs. Configure Slack Notifications for a Job: Open the job configuration page for the job you want to receive Slack notifications for. Slack Notifications: Under the “Post-build Actions” section, select “Slack Notification”. Channel: Choose the Slack channel where notifications should be sent for this job. You can also use a custom channel syntax like #my-custom-channel. Condition: Select the events for which you want to send Slack notifications. Options include “Always”, “Success”, “Failure”, “Unstable”, and “Not Built”. Message: Customize the message that will be sent to Slack. You can use variables like ${JOB_NAME}, ${BUILD_STATUS}, and ${BUILD_URL} to insert job-specific information. Save Jenkins Job Configuration: Click on the “Save” button to apply the Slack notification settings for the job. Now, whenever your Jenkins job starts, succeeds, or fails, a Slack notification will be sent to the specified channel, providing you with real-time updates on your build status. So now, we have a CI-ready Fastapi web application using Jenkins, slack, and GitHub webhooks.
  • 9. To sum it up, using Jenkins with Python for Continuous Integration can really change the way you develop software. It not only makes things faster but also helps in reducing mistakes, leading to a more efficient and smooth workflow. Automating various steps, like testing and deploying your software, is key to making sure it’s of good quality. With Jenkins and Python together, developers can create software that’s both trustworthy and strong. Plus, Jenkins has a lot of extra tools and resources that can make your Continuous Integration process even better. It’s a tool that can grow with your needs in today’s software development world. So, I suggest exploring these tools and resources to make the most out of Jenkins in your Python projects and see how far you can go with Continuous Integration. Also Learn: How to Integrate Apache Kafka with Spring Boot Originally published by: Continuous Integration using Jenkins with Python