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

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

In this detailed guide, we will walk you through the significant yet easy steps to configure Email to Salesforce. Without any further ado, let’s get started! About Email to Salesforce As the term refers, Email to Salesforce is valuable for any organization that businesses use as their Customer Relationship Management (CRM) platform. It helps streamline […]

Read More
Guide on CRUD Operations in Node.js with jsForce

CRM developers typically need to integrate Salesforce with Node.js apps. One well-known library for this purpose is jsForce, which provides a comprehensive set of tools for interacting with Salesforce data and performing CRUD tasks effectively. Let’s dive into the blog, where you will understand the use of jsForce to execute key CRUD tasks within Salesforce, […]

Read More
How to Implement Round Robin Assignments in Salesforce Using Apex

Ensuring a proper workload balance and quick follow-ups from internal or external team members, leads, opportunities, or task distributions is crucial. To achieve this, all you need is a Round Robin assignment. In this step-by-step guide, we will walk you through the process of implementing a round-robin assignment in Salesforce using Apex. Here, we’ve used […]

Read More
Best Salesforce Developments Services Provider

In this step-by-step guide, we will walk you through the significant role of Large Data Volumes in Salesforce, and what strategies or practices you should keep in mind. What is Large Data Volumes? In Salesforce, Large Data Volumes (LDV) refers to managing a huge amount of records available in the platform. LDV usually comes into […]

Read More

Salesforce Apex includes numerous built-in text handling classes, and in addition to them, the Pattern and Matcher classes are good for performing complex string operations. These classes enable us to define and work with regular expressions, which are of particular importance for data validation, searching, and modification. In this technical blog, we will find out […]

Read More

Maintaining security and compliance in Salesforce requires effective user access management. This article will lead you through the process of creating expiration dates for Permission Sets and Permission Set Groups, allowing you to automate access removal while minimizing manual work. Know how this functionality simplifies workflows, guarantees compliance, and improves security procedures. Why Use Expiration […]

Read More
Our Location worldwide
Indian Flag India
3rd Floor, A-10, Pegasus Tower, Sector 68, Noida, Uttar Pradesh 201301 +91-1203117884
United States of America Flag USA
333 West Brown Deer Road Unit G – 366 Milwaukee WI, USA 53217 +1(262) 310-7818
United Kingdom Flag UK
7 Bell Yard, London, WC2A 2JR +44 20 3239 9428
Canada Canada
HIC Global Solutions INC
43 Lafferty Lane, Richmond Hill, L4C 3N8, CA +1(262) 310-7818