0
0
Jenkinsdevops~10 mins

Webhook triggers from GitHub/GitLab in Jenkins - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a Jenkins pipeline that triggers on GitHub webhook events.

Jenkins
pipeline {
  agent any
  triggers {
    [1]()
  }
  stages {
    stage('Build') {
      steps {
        echo 'Building...'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
AgithubPush
Bcron
CpollSCM
Dtimer
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'pollSCM' instead of 'githubPush' triggers polling instead of webhook.
Using 'cron' or 'timer' triggers scheduled builds, not webhook events.
2fill in blank
medium

Complete the code to enable webhook trigger for GitLab in a Jenkins pipeline.

Jenkins
pipeline {
  agent any
  triggers {
    [1]()
  }
  stages {
    stage('Test') {
      steps {
        echo 'Testing...'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
AgitlabPush
BgitPush
CgitlabWebhook
DgitPushTrigger
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'gitPush' which is not a valid Jenkins trigger.
Using 'gitlabWebhook' which is not the correct trigger name.
3fill in blank
hard

Fix the error in the Jenkinsfile to correctly trigger on GitHub webhook push events.

Jenkins
pipeline {
  agent any
  triggers {
    [1]()
  }
  stages {
    stage('Deploy') {
      steps {
        echo 'Deploying...'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
AGitHubPush
Bgithubpush
Cgithub_push
DgithubPush
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase or snake_case versions causes Jenkins to not recognize the trigger.
4fill in blank
hard

Fill the blank to create a Jenkins pipeline that triggers on GitLab webhook push events and runs a build stage.

Jenkins
pipeline {
  agent any
  triggers {
    [1]()
  }
  stages {
    stage('Build') {
      steps {
        echo 'Building project...'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
ApollSCM
BgithubPush
CgitlabPush
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing GitHub and GitLab trigger names causes the webhook not to work.
Using 'pollSCM' triggers polling, not webhook events.
5fill in blank
hard

Fill the blanks to define a Jenkins pipeline that triggers on GitHub webhook push events, checks out code, and runs tests.

Jenkins
pipeline {
  agent any
  triggers {
    [1]()
  }
  stages {
    stage('Checkout') {
      steps {
        {{BLANK_3}} 'https://github.com/example/repo.git'
      }
    }
    stage('Test') {
      steps {
        echo 'Running tests...'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
AgithubPush
Cgit
Dcheckout
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'git' instead of 'checkout' for the code checkout step.
Using wrong trigger names for GitHub webhook events.