Developing a managed package in Salesforce while using Bitbucket and Git for version control and collaboration involves several steps.
This approach helps you manage your Salesforce code, configurations, and metadata in a version-controlled environment.
Here are detailed steps to develop a managed package in Salesforce using Bitbucket and Git:
- Salesforce Developer Edition Org:
If you don't already have one, sign up for a Salesforce Developer Edition org, which you will use for development and testing.
- Install Salesforce CLI:
Install the Salesforce Command Line Interface (CLI) on your local machine. The CLI allows you to interact with Salesforce from the command line.
- Install Salesforce Extensions for Visual Studio Code:Using Visual Studio Code for development is recommended, install the Salesforce Extensions for Visual Studio Code.
In your Salesforce Developer Edition org, create a new Salesforce DX project. This project will serve as the foundation for your package development.bash
# Navigate to your desired project directory
# Create a new Salesforce DX project
sfdx force:project:create -n MyPackageProject
Step 4: Develop Your Salesforce Package ComponentsAuthenticate your Salesforce DX project with your Developer Edition org by running the following command:bashsfdx force:auth:web:login -a MyDevOrg
Develop the custom objects, fields, Apex classes, Visualforce pages, Lightning components, and other components that make up your Salesforce package.
If you haven't already, initialise a Git repository in your project directory:bash#Initialize a Git repositorygit init
- Log in to your Bitbucket account.
- Click the '+' icon in the left sidebar and select 'Create repository.'
- Fill in the repository details, including name, description, and access level (public or private).
- Click 'Create repository' to create your Bitbucket repository.2.
Add your Salesforce DX project's files to the Git repository and commit them:
bash#Add all files to the Git repositorygit add .
#Commit the changesgit commit -m "Initial commit"
Connect your local Git repository to the Bitbucket repository you created:
bash#Replace <your_bitbucket_repository_url> with the actual URL of your Bitbucket repositorygit remote add origin <your_bitbucket_repository_url>
Push your code from your local Git repository to your Bitbucket repository:
bash#Push the code to Bitbucketgit push -u origin master
Use Salesforce DX commands to create a package that includes the metadata for your managed package:
bash#Create a new package (replace MyPackage with your desired package name)sfdx force:package:create -n MyPackage -d "My Package Description"
#Add package components (objects, classes, etc.) to the packagesfdx force:package:version:create -p MyPackage -x -w 30
Continue developing and testing your package features within your Salesforce DX project.
Step 12: Distribute Your Managed Package
- Complete the development of your managed package.
- Go through the necessary steps to package it, including metadata and security reviews.
- Distribute your managed package through Salesforce AppExchange or other appropriate channels.