How to enable jenkins to auto build with BitBucket server - Little Big Extra Skip to main content

How to enable jenkins to auto build with BitBucket server

 Integrate BitBucket webhook with Jenkins to auto build on push of code to a bitbucket repository

One of the goals of Continuous Integration andContinuous deployment is that once the code is pushed to the repository it should be tested, built and then packaged for deployment. BitBucket webhook makes is possible to trigger real-time notifications to Jenkins server so the auto build starts as soon as the code is pushed.

In this tutorial, we will

  • Add Jenkins add-on/plugin to BitBucket server
  • Install BitBucket Plugin in Jenkins
  • Configure Jenkins
  • Configure BitBucket

Add Jenkins add on to BitBucket server

Once you have installed BitBucket server on your machine, make sure that it is working. The default port is 7990, so you should be able to access it by using localhost: 7990.

  • Click on Settings and on the left side under ADD-ONS, click on Find new add-ons.
  • Search Jenkins and add the plugin

Install BitBucket Plugin in Jenkins

  • Make sure Jenkins is up and Running, in my case, it is running on localhost: 8080
  • In Jenkins go to Jenkins->Plugin Manager and install BitBucket Plugin and then restart Jenkins.

 enable jenkins to auto build with BitBucket server

Configure Jenkins

  • Now go the Job, which you have created and under Source Code Management Plugin, give the GIT Clone URL as shown below in the screenshot.
    BitBucket URL

 

  •  Under Build, Triggers make sure two boxes are checked
    a. Build when a change is published to BitBucket
    b. Poll SCM

build triggers

Configure BitBucket

  • Now go to BitBucket -> Repositories and select the repo for which are Jenkins has been configured

configure BitBucket

  • Click on the setting (icon on the left-hand side) and then hooks. Edit the Bitbucket Server Webhook to Jenkins
      a. Enter your Jenkins URL
      b. Repo Clone URL: Select the URL and the same protocol which BitBucket is providing you to clone. In case username is missing from the URL, we need to add it manually.I had to use Chrome Developer tools and remove the disabled flag from the input box and then add username manually.
    Ignore above step if the username is in URL
        c. Once it is enabled edit the URL with http://UserName@Server/gitrepo

CustomURL

  • Click on Trigger Jenkins if it says successful everything is fine.
    BitBucket server

 

  •  Commit some code and Jenkins should automatically start the build. Refresh the Jenkins page is auto refresh is disabled

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

Bitnami