What is a webhook in the context of GitHub or GitLab?
A webhook is a way for GitHub or GitLab to send a message to another system, like Jenkins, when something happens in a repository, such as a code push or pull request.
Click to reveal answer
beginner
How does Jenkins use webhooks from GitHub or GitLab?
Jenkins listens for webhook messages from GitHub or GitLab to automatically start a build or deployment when code changes are pushed.
Click to reveal answer
beginner
What is the main benefit of using webhook triggers in Jenkins pipelines?
The main benefit is automation: Jenkins can start jobs immediately after code changes, saving time and reducing manual work.
Click to reveal answer
intermediate
Which Jenkins plugin is commonly used to integrate GitHub webhooks?
The 'GitHub plugin' is commonly used to connect Jenkins with GitHub webhooks for triggering builds.
Click to reveal answer
intermediate
What must you configure in GitHub or GitLab to enable webhook triggers for Jenkins?
You must set the webhook URL in the repository settings pointing to your Jenkins server's webhook endpoint and select which events trigger the webhook.
Click to reveal answer
What event typically triggers a Jenkins build via a GitHub webhook?
AChanging the repository description
BA code push to the repository
COpening a new issue
DAdding a new collaborator
✗ Incorrect
A code push to the repository is the common event that triggers Jenkins builds via webhooks.
Which Jenkins plugin helps receive webhook calls from GitHub?
ADocker plugin
BSlack plugin
CGitHub plugin
DPipeline plugin
✗ Incorrect
The GitHub plugin allows Jenkins to receive webhook calls from GitHub.
Where do you configure the webhook URL in GitLab to trigger Jenkins?
ARepository Settings > Webhooks
BUser Profile > Webhooks
CGroup Settings > Integrations
DProject Wiki
✗ Incorrect
Webhook URLs are configured in the repository settings under Webhooks.
What protocol does Jenkins use to receive webhook calls from GitHub/GitLab?
AHTTP/HTTPS
BFTP
CSSH
DSMTP
✗ Incorrect
Webhooks use HTTP or HTTPS to send messages to Jenkins.
What is a common security measure when setting up webhooks for Jenkins?
AUsing FTP for webhook delivery
BAllowing anonymous access to Jenkins
CDisabling SSL
DUsing a secret token to verify webhook messages
✗ Incorrect
A secret token helps Jenkins verify that webhook messages are from a trusted source.
Explain how webhook triggers from GitHub or GitLab automate Jenkins builds.
Think about what happens when you push code and how Jenkins knows to start.
You got /3 concepts.
Describe the steps to configure a webhook in GitHub to trigger a Jenkins job.
Focus on the GitHub side setup before Jenkins reacts.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of setting up a webhook trigger in Jenkins for GitHub or GitLab?
easy
A. To manually run Jenkins jobs from the Jenkins dashboard
B. To automatically start Jenkins jobs when code is pushed or pull requests are created
C. To send email notifications after a Jenkins job completes
D. To backup Jenkins configuration files to GitHub or GitLab
Solution
Step 1: Understand webhook triggers
Webhook triggers connect GitHub/GitLab events to Jenkins jobs, starting them automatically.
Step 2: Identify the main use case
The main use is to start Jenkins jobs automatically on code pushes or pull requests.
Final Answer:
To automatically start Jenkins jobs when code is pushed or pull requests are created -> Option B
Quick Check:
Webhook triggers = automatic job start [OK]
Hint: Webhook triggers start jobs automatically on code changes [OK]
Common Mistakes:
Confusing webhook triggers with manual job runs
Thinking webhooks send emails
Assuming webhooks backup Jenkins files
2. Which Jenkins pipeline syntax correctly sets up a GitHub webhook trigger to start a job on push events?
easy
A. triggers { cron('H/5 * * * *') }
B. triggers { gitlabPush() }
C. triggers { githubPush() }
D. triggers { genericWebhook() }
Solution
Step 1: Recall GitHub webhook trigger syntax
Jenkins uses genericWebhook() inside triggers block for generic webhook triggers, including GitHub.
Step 2: Eliminate incorrect options
gitlabPush() is not a valid Jenkins trigger; githubPush() is not a standard Jenkins trigger; cron() is for scheduled jobs.
Final Answer:
triggers { genericWebhook() } -> Option D
Quick Check:
Generic webhook trigger = genericWebhook() [OK]
Hint: Use genericWebhook() for GitHub webhook triggers in Jenkinsfile [OK]
Common Mistakes:
Using gitlabPush() which does not exist
Confusing genericWebhook() with GitHub trigger
Using cron for webhook triggers
3. Given this Jenkins pipeline snippet, what will happen when a push is made to the GitHub repository?
A. The job will start automatically and print 'Building project'
B. The job will not start automatically; manual trigger needed
C. The job will fail due to syntax error in triggers
D. The job will start but skip the Build stage
Solution
Step 1: Analyze the triggers block
The genericWebhook() trigger means the job starts automatically on webhook events.
Step 2: Check the pipeline stages
The Build stage prints 'Building project' when the job runs.
Final Answer:
The job will start automatically and print 'Building project' -> Option A
Quick Check:
genericWebhook() triggers automatic build [OK]
Hint: genericWebhook() triggers auto build on webhook event [OK]
Common Mistakes:
Assuming manual trigger is needed
Thinking triggers block causes syntax error
Believing Build stage is skipped
4. A Jenkins job configured with GitLab webhook trigger does not start when code is pushed. Which is the most likely cause?
medium
A. The webhook URL in GitLab is incorrect or missing
B. The Jenkinsfile uses githubPush() trigger instead of GitLab webhook plugin
C. The Jenkins server is offline
D. The GitLab repository has no commits
Solution
Step 1: Check webhook configuration in GitLab
If the webhook URL is wrong or missing, GitLab cannot notify Jenkins to start the job.
Step 2: Consider other causes
Using githubPush() in Jenkinsfile won't trigger GitLab events; Jenkins offline stops all jobs; no commits means no push events.
Final Answer:
The webhook URL in GitLab is incorrect or missing -> Option A
Quick Check:
Webhook URL correct = trigger works [OK]
Hint: Verify webhook URL in GitLab settings first [OK]
Common Mistakes:
Ignoring webhook URL correctness
Confusing GitHub and GitLab triggers
Not checking Jenkins server status
5. You want to trigger a Jenkins job from GitLab using the Generic Webhook Trigger plugin. Which configuration step is essential to ensure the job starts only on push events?
hard
A. Use githubPush() trigger in Jenkinsfile and set GitLab webhook URL
B. Schedule the Jenkins job with cron to poll GitLab every 5 minutes
C. Configure the webhook in GitLab to send push event payloads and set the Generic Webhook Trigger to filter on push event type
D. Add a post-commit hook in GitLab that manually starts Jenkins jobs
Solution
Step 1: Set GitLab webhook to send push event payloads
GitLab must be configured to send push event data to Jenkins webhook URL.