GitHub Webhook: Non-Multibranch Jobs

Issue

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

Environment

Jenkins

Plugins

Github

Resolution

On Jenkins

A. Plugin Configuration

GitHub plugin as explained in GitHub Webhook configuration.

B. Job Configuration

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

For Freestyle and Pipeline jobs

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

Just For Freestyle:

Notes:
1. CloudBees GitHub Pull Request Builder plugin plugin requires Enable Git validated merge support enabled.
2. Both triggers can be selected together if it was needed in a Freestyle project. However Build pull requests to the repository trigger option is not available for Pipeline jobs. As a workaround, use Multibranch Pipeline and restrict the branch to build in Advanced options > Include branches to just the master (a Jenkinsfile in the master branch of the repo is needed).

IMPORTANT: 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-pull-request-hook/ for Pull request events.
  • <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:

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.