Environment
-
CloudBees Jenkins Enterprise - Managed controller (CJE-MM)
-
CloudBees Jenkins Team (CJT)
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 jobs
-
For PUSH events:
GitHub hook trigger for GITScm polling
(in the past named asBuild when a change is pushed to GitHub
) by GitHub plugin -
For PULL REQUEST events:
Build pull requests to the repository
by CloudBees GitHub Pull Request Builder plugin
-
-
For Pipeline jobs
-
Just PUSH events:
GitHub hook trigger for GITScm polling
(in the past named asBuild when a change is pushed to GitHub
) by GitHub plugin -
-
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 includesGitHub 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 } }
-
Notes:
-
CloudBees GitHub Pull Request Builder plugin plugin requires
Enable Git validated merge support
enabled. -
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 controller (aJenkinsfile
in the controller branch of the repo is needed).
If Manage hooks is enabled (Automatic mode) webhooks are generated after you Save the configuration of the job with the right triggers.
|
Troubleshooting
If the post-receive hooks are not there, please review this Troubleshooting guide