Loading...

In this concluding blog on BitBucket integration in Salesforce, we’ll proceed with the final step of pushing changes to the Bitbucket Repository for the ultimate deployment. The steps of creating the Apex class and LWC component for final deployment were covered in the previous blog.

So, Let’s get started with the final process without further delay.

Adding Repository variable in Bitbucket repository

After you have configured the BitBucket Pipeline file as shown in the previous blog, Click on Source control from the left sidebar.

Click on Source control

Generally Vs code automatically opens the repository available in the parent folder

If It does not open automatically, you will get a text like “A Git Repository found in the parent folder of the workspace or the open file” . Click on Open Repository.

Click on Open Repository

  • Click on bit bucket repo1.
  • Here you see all the changes in the repository
  • Enter any comment in the Message field. We are writing “Created lwc, apex with test class and yaml file configuration”.
  • Click on the drop-down on the right side of the commit button. Click on commit and push.

commit and push

It will push all the changes of bit bucket repo1 in the repository of Bitbucket. You can verify it by opening the bitbucket repository. It looks like below:

Open your Bitbucket repository left side menu and click on Repository settings. Scroll the left menu bar and click on the Repository variable.

Repository variable

Now, Add these value in Name and Value fields respectively andthe check secured check box for every value:

Name

  1. USERNAME_PROD
  2. USERNAME_UAT
  3. CONSUMER_KEY_UAT
  4. CONSUMER_KEY_PROD
  5. DECRYPTION_KEY_UAT
  6. DECRYPTION_KEY_PROD
  7. DECRYPTION_IV_PROD
  8. DECRYPTION_IV_UAT

 Value

  1. PROD username
  2. UAT Sandbox username
  3. UAT’s Consumer Key of ConnecTed app
  4. Production’s Consumer Key of Connected app
  5. Key generated to encrypt server.key for UAT
  6. Key generated to encrypt server.key for PROD
  7. Iv(initialization vector) generated to encrypt server.key for PRO
  8. Iv(initialization vector) generated to encrypt server.key for UAT

After adding all values it looks like below

Validate and Deploy Apex and LWC from Dev to UAT:

  • We have created two Branches for UAT, sub_uat and main_uat.
  • If we want to validate changes in UAT then we should merge Dev Branch to sub_uat.
  • After successfully validating the changes in UAT, we will deploy those changes in UAT by merging the sub_uat branch into main_uat.

Validate changes in UAT:

  • Open your Bitbucket repo1 Repository.
  • Click on Pull request in the left side menu bar. Click on Create pull request.
  • For Source Branch choose Dev and for Destination Branch choose sub_uat
  • Enter Title Dev To sub_uat.

You can add a Description and also add a reviewer who will review your code or changes.

Click on Create Pull Request.

A new Pull Request is created because here we don’t have any reviewers so we have to approve and merge the code by clicking on Merge.

Create Pull Request

When Merge is completed pipeline will run automatically.

  • Click on Pipeline.
  • Click on Merged in Dev (pull request #1) Dev To sub_uat you can see it will do things one by one.

Click on Merged in Dev

After some time validation will be successful.

validation

  • Now log into the Uat environment and from Setup>Deployment status.
  • Click on Deployment status and in the Succeeded section you will see deployment with Validate: succeeded status.

succeeded status

Deploy the changes in UAT:

  • Open your Bit bucket repo1 Repository.
  • Click on Pull request in the left side menu baR. Click on Create pull request.
  • For Source Branch choose sub_uat and for Destination Branch choose main_uat.
  • Enter Title sub_uat To main_uat.

You can add a Description and also add a reviewer who will review your code or changes.

  • Click on Create Pull Request.
  • A new Pull Request is created because here we don’t have any reviewers so we have to approve and merge the code by clicking on Merge.

When Merge is completed pipeline will run automatically.

  • Click on Pipeline.
  • Click on Merged in Dev (pull request #2) sub_uat To main_uat you can see it will do things one by one.

After some time Deployment will be successful.

  • Now log into Uat environment and from Setup>Deployment status.
  • Click on Deployment status and in Succeeded section you will see deployment with Deploy: succeeded status.

Now Apex class “firstApexClass” and its test class will be available in Uat. You can verify it from setup>Apex classes and there you will see your deployed apex classes.

deployed apex classes

For verify LWC from Setup>Custom Code>Lightning Components. And there you will find your deployed LWC.

deployed LWC

Finally, Validate and Deploy in the Production environment:

  • We have created two Branches for Production, sub_main and main.
  • If we want to validate changes in Production then we should merge main_uat Branch to sub_main.
  • After successfully validating the changes in Production to deploy changes in Production we will merge the sub_main branch into the main.

Validate changes in Production:

  • Open your Bit bucket repo1 Repository.
  • Click on Pull request in the left side menu bar. Click on Create pull request.
  • For Source Branch choose main_uat and for Destination Branch choose sub_main
  • Enter Title main_uat To sub_main.

You can add a Description and also add a reviewer who will review your code or changes.

  • A New Pull Request is created because here we don’t have any reviewers so we have to approve and merge the code by clicking on Merge.
  • When Merge is completed pipeline will run automatically. Click on Pipeline.

Validate changes in Production

  • Click on Merged in Dev (pull request #3) main_uat To sub_main you can see it will do things one by one.
  • After some time Validation will be successful.

After some time Validation will be successful

  • Now log into the Production environment and from Setup>Deployment status.
  • Click on Deployment status and in the Succeeded section you will see deployment with Validate: succeeded status.

Deploy changes in Production :

  • Open your Bit bucket repo1 Repository.
  • Click on Pull request in left side menu bar . Click on Create pull request.
  • For Source Branch choose sub_main and for Destination Branch choose main
  • Enter Title sub_main To main.
  • You can add Description and also add reviewer who will review your code or changes.
  • Click on Create Pull Request.
  • New Pull Request is created because here we don’t have any reviewer so we have to approve and merge the code by clicking on Merge.
  • When Merge is completed pipeline will run automatically. Click on Pipeline.

  • Click on Merged in Dev (pull request #4) sub_main To main you can see it will do things one by one.
  • After some time Deployment will be successful.
  • Now log into the Production environment and from Setup>Deployment status.
  • Click on Deployment status and in the Succeeded section you will see deployment with Deploy: succeeded status.
  • Now Apex class “firstApexClass” and its test class will be available in Uat. You can verify it from setup>Apex classes and there you will see your deployed Apex classes.

verify it from setup>Apex classes

For verify LWC from Setup>Custom Code>Lightning Components. And there you will find your deployed LWC.

verify LWC

Salesforce Experts

Conclusion:

Bitbucket is a powerful and flexible tool that can help you streamline your Salesforce development workflow and deliver better code faster. Compared to other version control tools such as GitLab or GitHub, Bitbucket offers more features and integrations for Salesforce developers, such as native support for Salesforce DX, Salesforce CLI, SFDX Scanner, and more.

Try out the solution in your org and feel free to contact us for any Salesforce Development solution!

Related Articles

Sticky notes aren’t just for your desk anymore! In this tutorial, we’ll create a Lightning Web Component (LWC) in Salesforce that allows you to pin notes on your app page or record page. With a clean, interactive UI, these digital sticky notes ensure you never forget important tasks or details. What Will You Learn? By […]

Read More
How to Create Dynamic, Animated Charts in Salesforce LWC using Chart.js

Bring Salesforce data to life with dynamic charts inside Lightning pages! While Salesforce dashboards are powerful, sometimes business users want visual insights without leaving their current page. That’s where Chart.js with Lightning Web Components (LWC) becomes a game-changer. In this step-by-step guide, you’ll learn how to: Upload Chart.js as a static resource in Salesforce. Build […]

Read More
How to Encrypt and Decrypt Data in Salesforce Using Apex Crypto Class

Data security is more important than ever. Whether you’re storing customer information, sensitive business data, or private communication, ensuring that your data stays safe is critical. Salesforce provides built-in tools to help with this, and one of the most powerful yet easy-to-use approaches is encryption and decryption using the Apex Crypto class. In this blog, […]

Read More
Benefits & Step-by-Step Setup Guide for Salesforce Code Analyzer

When building on the Salesforce platform, code quality and security are non-negotiable, especially before submitting your app for a Salesforce Security Review. Catching bugs and vulnerabilities early not only saves time but also ensures compliance with Salesforce’s best practices. That’s where the Salesforce Code Analyzer comes in. This open-source tool scans your Apex classes, triggers, […]

Read More
A Step-by-Step Guide to Integrate Zoho CRM with Salesforce (Without Coding)

Managing data across multiple CRMs can be a real challenge for businesses that want a single source of truth. If your teams use Zoho CRM but want to move or sync all records seamlessly into Salesforce, you don’t need to write a single line of code. Thanks to MultiSync Made Easy, the integration process is […]

Read More
How to Integrate Salesforce with Copilot

Integrating Salesforce with Copilot is becoming an essential step for organizations aiming to streamline workflows, automate client data management, and unlock the power of AI-driven CRM. By connecting these two platforms, businesses can centralize customer information, reduce manual tasks, and accelerate growth. This guide walks you through the Salesforce–Copilot integration process with clear steps, Apex […]

Read More