0
0
Jenkinsdevops~10 mins

Webhook triggers from GitHub/GitLab in Jenkins - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Webhook triggers from GitHub/GitLab
Code pushed to GitHub/GitLab
Webhook sends HTTP POST to Jenkins
Jenkins receives webhook
Jenkins matches webhook to job trigger
Jenkins starts the job
Job runs build/test/deploy steps
Job completes and reports status
When code is pushed, GitHub/GitLab sends a webhook to Jenkins, which triggers the matching job to run automatically.
Execution Sample
Jenkins
pipeline {
  agent any
  triggers {
    githubPush()
  }
  stages {
    stage('Build') { steps { echo 'Building...' } }
  }
}
This Jenkins pipeline triggers automatically when GitHub sends a push webhook, then runs the Build stage.
Process Table
StepEventJenkins ActionJob StatusOutput
1Code pushed to GitHubWebhook sent to JenkinsN/AHTTP POST sent
2Jenkins receives webhookMatches job triggerN/ATrigger matched: githubPush()
3Job startsBuild stage runsRunningEcho: Building...
4Job completesReports successSuccessBuild finished successfully
5Waiting for next webhookIdleIdleReady for next push
💡 Job completes after build stage, Jenkins waits for next webhook event
Status Tracker
VariableStartAfter Step 1After Step 2After Step 3After Step 4Final
Webhook ReceivedFalseTrueTrueTrueTrueFalse
Job StatusIdleIdleTriggeredRunningSuccessIdle
Key Moments - 3 Insights
Why does Jenkins start the job only after receiving the webhook?
Because Jenkins waits for the webhook HTTP POST from GitHub/GitLab to know when to trigger the job, as shown in execution_table step 2.
What happens if the webhook does not match any job trigger?
Jenkins ignores the webhook and does not start any job, so the job status stays Idle, as no trigger matched in step 2.
Why is the job status 'Running' during the build stage?
Because Jenkins is actively executing the build steps after trigger, as shown in step 3 where the job status changes to Running.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the job status at step 3?
ARunning
BSuccess
CIdle
DTriggered
💡 Hint
Check the 'Job Status' column in execution_table row for step 3
At which step does Jenkins match the webhook to the job trigger?
AStep 1
BStep 2
CStep 3
DStep 4
💡 Hint
Look at the 'Jenkins Action' column in execution_table to find when matching happens
If the webhook was never received, what would the final job status be?
ARunning
BSuccess
CIdle
DTriggered
💡 Hint
Refer to variable_tracker for 'Webhook Received' and 'Job Status' changes
Concept Snapshot
Webhook triggers from GitHub/GitLab:
- GitHub/GitLab sends HTTP POST webhook on code push
- Jenkins listens and matches webhook to job triggers
- Matching triggers start Jenkins jobs automatically
- Jobs run build/test/deploy stages
- Jenkins reports job status after completion
Full Transcript
When a developer pushes code to GitHub or GitLab, these platforms send a webhook, which is a simple HTTP POST message, to Jenkins. Jenkins listens for these webhooks and checks if any job is configured to trigger on such events. If a match is found, Jenkins starts the job automatically. The job runs its defined stages like build or test. After the job finishes, Jenkins reports the status and waits for the next webhook. This process automates running jobs right after code changes without manual intervention.