AWS Builder Center

Automating CI/CD with GitHub Actions, Jenkins, and GitHub Webhooks: A Beginner’s Guide

Description: Learn how GitHub Actions, Jenkins, and GitHub Webhooks help automate software development workflows. This beginner-friendly guide explains the concepts and demonstrates how to trigger a Jenkins pipeline automatically whenever code is pushed to GitHub.

Computer Engineering Undergraduate


1. Introduction

In software development, developers frequently update their code, test new features, fix bugs, and deploy applications. Performing these tasks manually every time can be repetitive and time-consuming.
This is where Continuous Integration (CI) and Continuous Delivery/Deployment (CD) become useful.
CI/CD helps automate important stages of software development, such as building, testing, and deploying applications.
In this article, we will explore three important technologies:
  • GitHub Actions: A platform for automating workflows directly within GitHub.
  • Jenkins: An open-source automation server used to build, test, and deploy applications.
  • GitHub Webhooks: A mechanism that sends event notifications from GitHub to external applications, such as Jenkins.
We will also learn how to configure a GitHub Webhook to trigger a Jenkins pipeline automatically when new code is pushed to a repository.

2. What is CI/CD?

CI/CD is a software development practice that helps teams deliver software more efficiently.
Continuous Integration (CI) means frequently integrating code changes into a shared repository and automatically building and testing those changes.
Continuous Delivery/Deployment (CD) focuses on preparing or automatically releasing the tested application.
A simple CI/CD process looks like this:
  1. A developer writes or modifies application code.
  1. The developer pushes the changes to GitHub.
  1. An automation tool detects the changes.
  1. The application is built and tested.
  1. If the process succeeds, the application can be deployed.
This reduces repetitive manual work and helps identify errors earlier.

3. What is GitHub Actions?

GitHub Actions is an automation platform built into GitHub. It allows developers to create workflows that run automatically when specific events occur.
For example, a workflow can run whenever someone pushes code to a repository or creates a pull request.

Important concepts

  • Workflow: An automated process defined in a YAML file.
  • Event: Something that triggers a workflow, such as a push or pull request.
  • Job: A group of steps that run together.
  • Step: An individual task, such as installing dependencies or running tests.
  • Runner: The machine that executes the workflow.
GitHub Actions workflows are usually stored inside:
 .github/workflows/ 
For example, a simple workflow file named  ci.yml  could look like this:
name: Simple CI Workflow

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Display a message
run: echo "GitHub Actions is working!"
Whenever code is pushed to the  main  branch, GitHub Actions starts this workflow and executes the defined steps.

4. What is Jenkins?

Jenkins is an open-source automation server widely used in CI/CD pipelines.
It helps developers automate tasks such as:
  • Building applications.
  • Running automated tests.
  • Integrating code changes.
  • Creating Docker images.
  • Deploying applications to servers.
Jenkins uses pipelines to define the steps required to automate a software development process.
A pipeline can be written in a file called  Jenkinsfile .

What is a Jenkinsfile?

A Jenkinsfile is a text file that defines the stages and steps of a Jenkins pipeline.
For example:
pipeline {
agent any

stages {
stage('Build') {
steps {
echo 'Building the application...'
}
}

stage('Test') {
steps {
echo 'Testing the application...'
}
}

stage('Deploy') {
steps {
echo 'Deploying the application...'
}
}
}
}
This example contains three stages: Build, Test, and Deploy.
When Jenkins executes the pipeline, it runs these stages in order.

5. What is a GitHub Webhook?

A GitHub Webhook is a feature that allows GitHub to send an HTTP request to another application when a specific event occurs.
For example, when a developer pushes new code to GitHub, GitHub can send a notification to Jenkins.
Jenkins receives the notification and can start the configured pipeline.

How does it work?

Consider the following process:
  1. A developer makes changes to an application.
  1. The developer commits and pushes the changes to GitHub.
  1. GitHub detects the push event.
  1. GitHub sends an HTTP POST request to the configured Jenkins webhook endpoint.
  1. Jenkins receives the notification.
  1. Jenkins starts the pipeline.
  1. The pipeline builds and tests the application and can proceed to deployment.
Important: A webhook does not perform the build itself. It notifies Jenkins that an event has occurred. Jenkins is responsible for executing the pipeline.

6. Practical Implementation: Connecting GitHub with Jenkins Using a Webhook

Now let's understand how to connect GitHub and Jenkins so that a code push automatically triggers a Jenkins pipeline.

Step 1: Prepare the requirements

Before starting, make sure you have:
  • A GitHub account.
  • A GitHub repository containing your application.
  • A running Jenkins server.
  • A Jenkins pipeline configured to use your GitHub repository.
  • A Jenkins server that GitHub can reach through a publicly accessible HTTPS endpoint.
If Jenkins is running on an AWS EC2 instance, make sure the network and security group configuration allow the required connection.
Do not expose Jenkins unnecessarily to the public internet. Use HTTPS, authentication, appropriate firewall rules, and secure credentials.

Step 2: Configure Jenkins

  1. Open your Jenkins dashboard.
  1. Navigate to Manage Jenkins → Plugins.
  1. Find and install the GitHub plugin if it is not already installed.
  1. Create a new Jenkins job.
  1. Select Pipeline as the job type.
  1. Configure the job to retrieve its pipeline definition from your GitHub repository.
For a Pipeline from SCM configuration:
  • Select Git as the SCM.
  • Enter your GitHub repository URL.
  • Configure credentials if the repository is private.
  • Select the correct branch, such as  main .
  • Set the script path to  Jenkinsfile .
Under Build Triggers, enable:
 GitHub hook trigger for GITScm polling 
Save the job configuration.

Step 3: Add a GitHub Webhook

Now configure GitHub to notify Jenkins whenever code is pushed.
  1. Open your GitHub repository.
  1. Navigate to Settings.
  1. Select Webhooks.
  1. Click Add webhook.
  1. Enter the following webhook URL:
https://YOUR_JENKINS_DOMAIN/github-webhook/
Replace  YOUR_JENKINS_DOMAIN  with your actual publicly accessible Jenkins domain.
  1. Set the content type to:
application/json
  1. Select Just the push event if you only want to trigger Jenkins when code is pushed.
  1. Enable the webhook and click Add webhook.
If your Jenkins configuration supports a webhook secret, configure the same secret securely on both sides.

Step 4: Test the Webhook

Now let's check whether the connection works.
  1. Open your GitHub repository.
  1. Make a small change to a file.
  1. Commit and push the changes to the configured branch.
  1. Open your Jenkins dashboard.
  1. Check the pipeline's build history.
If everything is configured correctly, Jenkins should automatically start a new build after receiving the webhook notification.
You can also check the webhook's delivery history under:
GitHub → Repository Settings → Webhooks → Recent Deliveries
This helps identify whether GitHub successfully delivered the event.

Step 5: Understand the Jenkins Pipeline Execution

After Jenkins receives the notification, it retrieves the latest repository changes and executes the pipeline.
For example:
Developer pushes code
|
v
GitHub Repository
|
v
GitHub Webhook
|
v
Jenkins Server
|
v
Jenkins Pipeline
|
v
Build Application
|
v
Run Tests
|
v
Deploy Application
This is how developers can automate their application workflow without manually starting every Jenkins build.

7. GitHub Actions vs Jenkins

Both GitHub Actions and Jenkins can automate CI/CD workflows, but they have different approaches.
Feature
GitHub Actions
Jenkins
Type
GitHub automation platform
Open-source automation server
Hosting
GitHub-hosted or self-hosted runners
Usually self-managed or cloud-hosted
Configuration
YAML workflows
Jenkinsfile
Integration
Built into GitHub
Integrates with many tools and plugins
Maintenance
GitHub manages hosted runners
You manage the Jenkins environment
Customization
Flexible workflows and actions
Highly customizable through plugins

Which one should beginners learn?

Both are valuable technologies.
GitHub Actions is a convenient starting point because it is integrated into GitHub.
Jenkins is useful for learning how CI/CD pipelines work, configuring automation servers, integrating external tools, and managing deployment workflows.
Learning both can help you understand different approaches to software automation.
Remember: GitHub Actions and Jenkins are separate automation systems. You do not need GitHub Actions to trigger Jenkins. In our practical example, GitHub Webhooks notify Jenkins directly.

8. Common Problems and Troubleshooting

While configuring GitHub Webhooks with Jenkins, you may encounter some common problems.
Problem 1: Jenkins does not start a build
Possible reasons:
  • The webhook URL is incorrect.
  • The Jenkins job does not have the GitHub hook trigger enabled.
  • The Jenkins server is not reachable from GitHub.
Check the webhook delivery history and Jenkins job configuration.
Problem 2: Webhook delivery fails
Possible reasons:
  • Incorrect webhook endpoint.
  • Network or firewall restrictions.
  • Jenkins server is unavailable.
  • HTTPS or certificate configuration problems.
Check that the Jenkins endpoint is accessible and correctly configured.
Problem 3: Jenkins cannot access the GitHub repository
Possible reasons:
  • Incorrect repository URL.
  • Missing or invalid credentials.
  • Incorrect branch configuration.
Check the Jenkins SCM configuration and repository permissions.
Problem 4: Pipeline execution fails
Possible reasons:
  • Errors in the Jenkinsfile.
  • Missing dependencies.
  • Incorrect build commands.
  • Environment configuration problems.
Review the Jenkins console output to identify the error.

9. What Have We Learned?

Through this tutorial, we explored:
  • The meaning of CI/CD.
  • How GitHub Actions automates workflows.
  • How Jenkins manages CI/CD pipelines.
  • How GitHub Webhooks notify external applications.
  • How to connect GitHub with Jenkins.
  • How to trigger a Jenkins pipeline automatically after a code push.
  • Common configuration problems and troubleshooting methods.

10. Conclusion

Automation is an important part of modern software development and DevOps engineering.
GitHub Actions, Jenkins, and GitHub Webhooks help developers reduce manual work and create more reliable development workflows.
By understanding how these technologies work together, beginners can take an important step toward building practical CI/CD pipelines.
Start with a small application, configure a simple pipeline, and gradually explore automated testing, Docker image creation, and cloud deployment.
Keep learning, keep building, and keep automating!

Useful Resources

Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article