{"id":8366,"date":"2018-02-08T03:01:54","date_gmt":"2018-02-08T08:01:54","guid":{"rendered":"https:\/\/qxf2.com\/blog\/?p=8366"},"modified":"2018-03-29T10:38:27","modified_gmt":"2018-03-29T14:38:27","slug":"blog-post-on-how-to-connect-bitbucket-with-jenkins","status":"publish","type":"post","link":"https:\/\/qxf2.com\/blog\/blog-post-on-how-to-connect-bitbucket-with-jenkins\/","title":{"rendered":"Bitbucket integration with Jenkins"},"content":{"rendered":"<p>In this post, we will learn to setup Continuous Integration using Jenkins and Bitbucket. As soon as a commit happens on Bitbucket, it should trigger a Jenkins Job. To do this, we are going to create webhook on Bitbucket and supply it to a Jenkins job. This webhook will notify Jenkins about all new commits, information about the branch, commits that are made, etc.<\/p>\n<hr \/>\n<h3>Why this post?<\/h3>\n<p>We did not find a short explanation about configuring Bitbucket with Jenkins. So wanted to consolidate that information in one post.<\/p>\n<hr \/>\n<h3>Overview of integrating Bitbucket and Jenkins<\/h3>\n<p>1. Install a Jenkins plugin for Bitbucket<br \/>\n2. Configure your Jenkins job with Bitbucket repository details<br \/>\n3. Verify your Jenkins configuration looks ok<br \/>\n4. Configure a Webhook on Bitbucket<br \/>\n5. Exercise your integration<br \/>\n6. Check the Bitbucket Hook log<\/p>\n<hr \/>\n<h3>Detailed guide to integrate Jenkins and Bitbucket<\/h3>\n<p><strong>1.Install and configure a Jenkins plugin for Bitbucket <\/strong><br \/>\nThis can be done under <strong>Manage Jenkins<\/strong> &#8212; <strong>Manage Plugins<\/strong> &#8212; Search for <strong>Bitbucket Plugin<\/strong> and install the same.To know more about the Bitbucket plugin,can have a\u00a0look at <a href=\"https:\/\/wiki.jenkins.io\/display\/JENKINS\/BitBucket+Plugin\">https:\/\/wiki.jenkins.io\/display\/JENKINS\/BitBucket+Plugin<\/a>.<\/p>\n<p><strong>2. Configure your Jenkins job with Bitbucket repository details<\/strong><br \/>\nConfigure Bitbucket Repository under Source Code Management, along with credentials.<\/p>\n<p><a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/01\/source_code_management-1.png\" data-rel=\"lightbox-image-0\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8387\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/01\/source_code_management-1.png\" alt=\"source_code_management\" width=\"1533\" height=\"875\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/01\/source_code_management-1.png 1533w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/01\/source_code_management-1-300x171.png 300w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/01\/source_code_management-1-768x438.png 768w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/01\/source_code_management-1-1024x584.png 1024w\" sizes=\"auto, (max-width: 1533px) 100vw, 1533px\" \/><\/a><\/p>\n<p><strong>3. Verify your Jenkins configuration looks ok<\/strong><br \/>\nTo check whether Bitbucket Plugin got installed on Jenkins, go to <strong>Job<\/strong>&#8212;<strong>Build Triggers<\/strong> and you should be able to see option as &#8220;<strong>Build when a change is pushed to BitBucket<\/strong>&#8221;<\/p>\n<p><a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/01\/bitbucket_plugin-1.png\" data-rel=\"lightbox-image-1\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8389\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/01\/bitbucket_plugin-1.png\" alt=\"bitbucket_plugin\" width=\"1125\" height=\"307\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/01\/bitbucket_plugin-1.png 1125w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/01\/bitbucket_plugin-1-300x82.png 300w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/01\/bitbucket_plugin-1-768x210.png 768w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/01\/bitbucket_plugin-1-1024x279.png 1024w\" sizes=\"auto, (max-width: 1125px) 100vw, 1125px\" \/><\/a><\/p>\n<p><strong>4.\u00a0Configure a Webhook on Bitbucket<\/strong><br \/>\nOn Bitbucket, go to <strong>Settings<\/strong> &#8212; <strong>Webhook<\/strong> &#8212; <strong>Add Webhook<\/strong>.<\/p>\n<p><a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/01\/Webhook-1.png\" data-rel=\"lightbox-image-2\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8384\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/01\/Webhook-1.png\" alt=\"configuring a webhook on Bibucket\" width=\"1651\" height=\"841\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/01\/Webhook-1.png 1651w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/01\/Webhook-1-300x153.png 300w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/01\/Webhook-1-768x391.png 768w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/01\/Webhook-1-1024x522.png 1024w\" sizes=\"auto, (max-width: 1651px) 100vw, 1651px\" \/><\/a><\/p>\n<p>Add a Webhook, as above given in the picture.The format of the URL is <span>\u00a0http<strong>:\/\/&lt;jenkins IP-address&gt;<\/strong>\/bitbucket-hook<\/span>\u00a0. The webhook should be active. So, click the option &#8220;active&#8221;. Under &#8220;<strong>Triggers<\/strong>&#8221; add &#8220;<strong>Repository Push<\/strong>&#8221; option and save the Webhook.<\/p>\n<p><strong>NOTE:<\/strong> Trailing slash should be there at the end of\u00a0 URL.<\/p>\n<p><strong>5. Exercise your integration<\/strong><br \/>\nMake a change to your code base and push it to Bitbucket. Check on Jenkins whether build gets triggered.<\/p>\n<p><a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/02\/git.png\" data-rel=\"lightbox-image-3\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8433\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/02\/git.png\" alt=\"git\" width=\"1057\" height=\"282\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/02\/git.png 1057w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/02\/git-300x80.png 300w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/02\/git-768x205.png 768w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/02\/git-1024x273.png 1024w\" sizes=\"auto, (max-width: 1057px) 100vw, 1057px\" \/><\/a><\/p>\n<p><strong>6. Check the Bitbucket Hook log<\/strong><br \/>\nOn Jenkins, when the build is triggered by Bitbucket webhook, you can check the activity under <strong>BitBucket Hook Log<\/strong>.<\/p>\n<p><a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/01\/bitbucket_hook_log-1.png\" data-rel=\"lightbox-image-4\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8394\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/01\/bitbucket_hook_log-1.png\" alt=\"bitbucket_hook_log\" width=\"1734\" height=\"667\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/01\/bitbucket_hook_log-1.png 1734w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/01\/bitbucket_hook_log-1-300x115.png 300w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/01\/bitbucket_hook_log-1-768x295.png 768w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/01\/bitbucket_hook_log-1-1024x394.png 1024w\" sizes=\"auto, (max-width: 1734px) 100vw, 1734px\" \/><\/a><\/p>\n<p>In this way, we can do Bitbucket Integration with Jenkins. <strong>If you liked this article, learn more <a href=\"https:\/\/qxf2.com\/blog\/about-qxf2\/\">about Qxf2&#8217;s<\/a> testing services for startups.<\/strong><\/p>\n<hr \/>\n<h3>References<\/h3>\n<p>1. <a href=\"https:\/\/www.youtube.com\/watch?v=nNaR5Q_pIa4\" data-rel=\"lightbox-video-0\">A useful 8-minute video <\/a><\/p>\n<p>2. <a href=\"https:\/\/bjurr.com\/continuous-integration-with-bitbucket-server-and-jenkins\/\">A more developer-friendly version of this post<\/a><\/p>\n<hr \/>\n","protected":false},"excerpt":{"rendered":"<p>In this post, we will learn to setup Continuous Integration using Jenkins and Bitbucket. As soon as a commit happens on Bitbucket, it should trigger a Jenkins Job. To do this, we are going to create webhook on Bitbucket and supply it to a Jenkins job. This webhook will notify Jenkins about all new commits, information about the branch, commits [&hellip;]<\/p>\n","protected":false},"author":21,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[143,52,51],"tags":[],"class_list":["post-8366","post","type-post","status-publish","format-standard","hentry","category-bitbucket","category-continuous-integration","category-jenkins"],"_links":{"self":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/8366","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/users\/21"}],"replies":[{"embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/comments?post=8366"}],"version-history":[{"count":28,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/8366\/revisions"}],"predecessor-version":[{"id":10966,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/8366\/revisions\/10966"}],"wp:attachment":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/media?parent=8366"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/categories?post=8366"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/tags?post=8366"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}