0
0
Jenkinsdevops~20 mins

Webhook triggers from GitHub/GitLab in Jenkins - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Webhook Trigger Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
How does a webhook trigger Jenkins from GitHub?

Which statement best describes how a webhook triggers a Jenkins job from GitHub?

AGitHub sends an HTTP POST request to Jenkins when an event occurs, and Jenkins starts the job based on that request.
BJenkins polls GitHub every minute to check for new commits and triggers the job if changes are found.
CGitHub pushes the entire repository to Jenkins, which then runs the job automatically.
DJenkins sends a request to GitHub to start the webhook when a build is needed.
Attempts:
2 left
💡 Hint

Think about who initiates the communication when code changes happen.

💻 Command Output
intermediate
2:00remaining
Jenkins webhook payload validation

What will Jenkins log show if it receives a webhook payload from GitLab with an invalid secret token?

Jenkins
Started by GitLab push webhook.
Secret token does not match. Ignoring the request.
AStarted by GitLab push webhook. Secret token does not match. Ignoring the request.
BBuild started successfully for the push event.
CError: Unable to parse webhook payload.
DWebhook received but no matching job found.
Attempts:
2 left
💡 Hint

Check what happens when the secret token is wrong.

Configuration
advanced
2:00remaining
Configuring Jenkins to trigger on GitHub pull request events

Which Jenkinsfile snippet correctly configures a pipeline to trigger only on GitHub pull request events using a webhook?

Jenkins
pipeline {
  agent any
  triggers {
    githubPullRequest()
  }
  stages {
    stage('Build') {
      steps {
        echo 'Building pull request...'
      }
    }
  }
}
Atriggers { pollSCM('H/5 * * * *') }
Btriggers { githubPullRequest() }
Ctriggers { cron('H/5 * * * *') }
Dtriggers { githubPush() }
Attempts:
2 left
💡 Hint

Look for the trigger that listens specifically to pull requests.

Troubleshoot
advanced
2:00remaining
Why does Jenkins not trigger on GitLab webhook despite correct URL?

You configured a GitLab webhook to trigger Jenkins on push events. The webhook URL is correct, but Jenkins does not start the job. What is the most likely cause?

AThe Jenkins server is offline and cannot receive webhooks.
BThe GitLab webhook is set to trigger on merge requests instead of push events.
CThe secret token configured in Jenkins does not match the token set in GitLab webhook settings.
DThe Jenkins job is disabled.
Attempts:
2 left
💡 Hint

Check the security settings that validate webhook authenticity.

🔀 Workflow
expert
3:00remaining
Order of steps for setting up GitHub webhook to trigger Jenkins pipeline

Arrange the steps in the correct order to set up a GitHub webhook that triggers a Jenkins pipeline on push events.

A1,3,2,4
B1,2,3,4
C3,2,1,4
D3,1,2,4
Attempts:
2 left
💡 Hint

Think about setting security before adding webhook and testing.