An alternate approach to CI/CD for WSO2 using Bitbucket and Bitbucket Branch Source Plugin

Photo by JJ Ying on Unsplash

Background

Continuous integration and continuous deployments have become a popular DevOps approach for increasing the efficiency of the software development lifecycle. Using Maven for builds, releases, and deployments is the most predominant CI/CD approach for WSO2 integration artifacts. Having said that, certain reasons such as aligning your organization’s existing CI/CD process to align with WSO2 releases can prompt the DevOps to take alternate approaches to CI/CD.

Approach

Two environments Dev and Prod are used for demonstration purposes. It can be extended to additional environments and pipelines. The methodology can be depicted at a high level using the following diagrams.

Full CI/CD process
Dev CI/CD Pipeline
Prod CI/CD Pipeline

Prerequisites

  • Installing and configuring Java 8 on your machine.
  • Installing and configuring Maven on your machine.
  • Two WSO2 Enterprise Integrator 6.X.X instances available to simulate the Dev and Prod environments. Tip you can run multiple WSO2 EI servers in the same machine by configuring the port offset in the <EI_HOME>/conf/carbon.xml file

Implementation

Configure the Bitbucket Server

  • Go into <bitbucket_home>/bin and start it by executing ./start-bitbucket.sh
  • Create a project in Bitbucket called wso2.
Bitbucket Project
Bitbucket Repository
  • Now that the codebase is ready, a webhook needs to be configured to invoke the Jenkins job in the availability of a new push. This can be achieved by traversing to Repository settings → Webhooks → Create webhook from the left menu. Provide the name as Jenkins and the URL as http://localhost:8080/bitbucket-scmsource-hook/notify?server_url=http%3A%2F%2Flocalhost%3A7990 given that the Jenkins server is running on port 8080 and the Bitbucket server is running on port 7990. Select “Push” under the Events section and make sure the webhook is active. Click create to provision the webhook.
Jenkins Webhook
  • Initially it is required to install the required plugins in Jenkins. Navigate to Jenkins Dashboard → Manage Jenkins → Manage Plugins page. From the available section install the Bitbucket Branch Source plugin, Jenkins Git plugin and Basic Branch Build Strategies plugin.
  • Configure the Bitbucket Endpoint in Jenkins by navigating to Jenkins Dashboard → Manage Jenkins → Configure System and scrolling to Bitbucket Endpoints section.
Configure Bitbucket Endpoint
Configure Global Pipeline Library
Create New Item
Bitbucket Branch Source Plugin Config 1
Provision Bitbucket Credentials in Jenkins
Bitbucket Branch Source Plugin Config 2
Bitbucket Branch Source Plugin Config 3
Multibranch Pipeline Scan Log
Discovered Branches and Tags

Testing

  • Developer machine to Dev environment
git add pom.xmlgit commit -m “updating pom file”git push origin master
Successfully Built Branch
Car file copied to file system
Car file deployed in EI Dev
git tag -a v1.0.0 -m “tagging v1.0.0”git push origin v1.0.0
User input for Prod Deployment
Successfully Built Tag
Car file copied to file system
Car file deployed in EI Prod

References