Thursday 30 June 2016

Jenkins Webhook, Only build Specific Branch after receiving web hook. e.g. only build master

With a web hook a request is made regardless of which branch it is on. Initially this would cause my Jenkins to initiate a build (on master) even when the commit was pushed to develop. To fix this we can follow these steps:


  • Open your jenkins project
  • configure it to use: Poll SCM (but leave the schedule blank)
  • save and exit

in Bitbucket / Github create a web hook and enter the following url (replacing your jenkins & git project details)

http://<your domain>/jenkins/git/notifyCommit?url=<your git repository url>
eg

http://fakewebsite.com:8080/jenkins/git/notifyCommit?url=git@bitbucket.org:faceuser/fakeproject.git

This will do the following:

  1. Send a web hook request to your jenkins
  2. Jenkins will process this request and look for Jenkins projects using the specified gitproject (e.g. git@bitbucket.org:faceuser/fakeproject.git)
  3. Jenkins will then poll git looking for changes on the specified branch





No comments:

Post a Comment