GitHub Webhook: Non-Multibranch Jobs

Article ID:115003015691
1 minute readKnowledge base

Issue

  • How to make GitHub trigger Freestyle jobs or Pipelines in Jenkins.

Resolution

On Jenkins

A. Plugin Configuration

B. Job Configuration

In the Job configuration, one of the following Build Triggers needs to be selected :

  • For Freestyle jobs

    • For PUSH events: GitHub hook trigger for GITScm polling (in the past named as Build when a change is pushed to GitHub)

  • For Pipeline jobs

    • For PUSH events: GitHub hook trigger for GITScm polling (in the past named as Build when a change is pushed to GitHub)

    • JENKINS-35132

      • The job has to be successfully executed manually one time in order for the push trigger and the git repo to be registered

      • Example of Jenkinsfile (Note that it includes GitHub hook trigger for GITScm polling enabled)

        properties([pipelineTriggers([githubPush()])]) node { stage ('Checkout'){ git branch: 'exampleBranch', url: 'https://github.com/example-org/example-repo.git' } stage ('Build'){ // steps } stage ('Test'){ // steps } }
If Manage hooks is enabled (Automatic mode) webhooks are generated after you Save the configuration of the job with the right triggers.

On GitHub

C. Validate GitHub WebHook

Make sure post-receive hooks has been created on GitHub at the Repository specify in the SCM configuration of the job as follows:

  • <JENKINS_URL>/github-webhook/ (push) for Push events.

GH_webhook_nonMultiBranch.png

Troubleshooting

If the post-receive hooks are not there, please review this Troubleshooting guide

Tested products/plugins version

The latest update of this article was tested with: