Learn how to set up CICD on Bitbucket Pipelines with the Vlocity CLI. This tutorial will teach you the basics to get started on using CICD to deploy omnistudio/vlocity datapacks with Bitbucket.
To get started, we will cover following setup on this tutorial
- use of a docker image installed with the sfdx cli, vlocity cli and puppeteer
- bitbucket repository variable credentials setup with OAuth token
- deploy only delta omnistudio datapacks files
- configure the yaml file
- check omnistudio datapacks are valid
- deploy omnistudio datapacks to the target org
- support for puppeteer on chromium for a headless browser to auto activate Omnistudio FlexCard and OmniScripts once deployed
How to Setup the Docker Image
First option, you skip manually building image the directly refer to the docker repo https://hub.docker.com/r/olopsman/bitbucket-vlocity
Second option, you can manually build and customize the image by cloning from my github project. The Dockerfile contains all the necessary software to install that would be used later for deployment. Build the docker image and push the to your own docker repo.
How to Setup the Repository Project
You can clone this existing vlocity project template which contains the yml file to be used by Bitbucket and the vlocity cli plus some the .gitignore files which you can customize further.
The repository basically contains the following directories and files.
config/ force-app/ vlocity/ .forceignore .gitignore .bitbucket-pipeline.yml - contains the build steps to use the image and runs the deployment README.md sfdx-projec.json vlocity-package.yaml
Update the bitbucket-pipeline.yml if you are hosting your own docker repo image.
# custom docker image based on bitbucket image image: olopsman/bitbucket-vlocity
Create a new Bitbucket repository and add that as a remote origin in the local project. Then push the local project to Bitbucket.
How To Setup the OAuth Token Variable
Authentication method – authorize an org and grab the sfdxurl to be stored as repository variable in Bitbucket.
Open up VSCode then open up the terminal or command prompt then run the following to sfdx authentication command
After you have successfully logged in, run the following command
sfdx force:org:display --verbose
From the results, copy the SFDX Auth URL.
- Create a repository variable AUTH_URL in Bitbucket and store the copied value.
- Also create another repository variable USER and enter your salesforce username.
How to Start a Deploying Through the Pipeline
On VSCode you should already have the SFDX cli installed, next also install the Vlocity CLI extension. After installation you should be able to refresh and deploy Omnistudio datapacks from your dev org.
First create a branch for the feature development. The naming of the branch is important. Branch name should start with “feature”. Eg. feature/ADO-73232
Next, retrieve the Omnistudio datapack you want to deploy using the Vlocity extension.
Commit those changes and push the local branch to the remote repository.
Make a pull request from the feature branch to the master branch. This should trigger the pipeline to run the cleanOrgData and validate the local data
vlocity -sfdx.username $USER -job vlocity-package.yaml cleanOrgData vlocity -sfdx.username $USER -job vlocity-package.yaml validateLocalData
Once this is successful, merge the Pull Request. This should deploy to the target org.
vlocity -sfdx.username $USER -job vlocity-package.yaml packUpdateSettings # cleans the org before deploy. - vlocity -sfdx.username $USER -job vlocity-package.yaml packDeploy # validate package is valid.
That should also auto activate any Omnistudio OmniScript or FlexCard once you deploy to the org as we have installed puppeteer on our image.
Hope you find this start template usefaul and helps you in your deployment. If you want to incorporate SFDX deployment further please check my previous blog post on this SFDX delta deployment.
One thought on “How To Set Up CICD On Bitbucket Pipelines With the Vlocity CLI”
[…] Use the Vlocity build tool – a command line tool. I wrote a blog post on how to use this for CICD […]