Understanding branches for Salesforce project
When you create an analysis project from Salesforce, the org or sandbox you authorize, will become your main branch. You can add your sandboxes as analysis project branches by editing your project (from the Project Analysis page). This allows for easy comparison between the production orgs or sandboxes and is especially good for checking features before production.
- Select your Salesforce project from the My Projects screen.
- Go to the More tab and select Project Analysis from the dropdown.
- Click on Edit Project.
- Click on button to add a new branch.
- Assign a name to your branch and choose the branch type:
- Comparison Branch- This branch determines only the recent issues in a project branch based on comparing with the standard branch in your project.
- Standard Branch- This branch will have your project's entire history and dashboards.
- Select your Salesforce environment.
- Once you click on Authorize, it will redirect you to the Salesforce login page to validate your credentials.
- This triggers the project analysis and the project being added under your CodeScan organization.
- You'll be redirected to the Project Analysis screen, where you can view the status of your triggered analysis.
Features of a comparison branch
When you create a comparison branch, the issues shown are only the new ones in that branch, not the general issues you see in the project's main branch.
The property below is responsible for changing the UI labels and texts from Pull Requests to Comparison Branches.
Points to Note:
codescan.comparison.branches property is in OFF state by default.
The comparison branches feature is enabled automatically when you:
- create new comparison branch via CodeScan user interface inside project with Salesforce as the integration type or,
- run sonar-scanner or CodeScan SFDX utility with these two new scanner properties:
Another way is via Autorabit-CodeScan integration.
The new properties
sonar.comparison.base are equivalents/aliases of these existing two:
So, because they are equivalents - the rest logic will be the same. If you mark any issue as
False Positive or
Resolve as Won't fix in your Comparison Branch, then this issue will not re-appear in base branch (master) after changes are merged.
Similarly, the new comparison branches reflect the changes on issues made by the user on the project’s main branch.
To test the new feature using sonar-scanner:
- Execute the initial analysis on base branch using the below command:
sonar-scanner -Dsonar.host.url=https://app.codescan.io -Dsonar.organization=<org-id> -Dsonar.projectKey=<project-key> -Dsonar.login=<security-token>
- Execute analysis on a comparison branch:
sonar-scanner -Dsonar.host.url=https://app.codescan.io -Dsonar.comparison.branch=<comparison-branch-name> -Dsonar.comparison.base=<base-branch-name> -Dsonar.organization=<org-id> -Dsonar.projectKey=<project-key> -Dsonar.login=<security-token>
On your Project Analysis page, go to Project Setting > Branches.
On this page, you can:
- View the branches you have created and segregated into master branches (including standalone branches) and comparison branches in two different tabs.
- Delete all the branches except the main branch.
- Renaming of the branch applies only to the main branch.
Delete a branch
For example, to delete a comparison branch, navigate to the Comparisons Branches tab, click on icon and click on Delete Comparison Branch. Note that this process cannot be undone.
Rename the main branch
To update the name of the main branch, navigate to the Branches tab, and look for the main branch.
Click on icon under the Actions tab and click on Rename branch.
Give the main branch a new name and click on Rename.
- Select your Salesforce project from the My Projects page.
- When you click on the main branch dropdown for your project, you can see the list of all branches that you have created or added.
- If there are any violations for your branch, such details will appear. If you click on a branch, the details of the violations can be seen on the Quality Gate Status screen.
All new branches added in this way will be deleted in 30 days if they are not analyzed again.
If you have any further questions about CodeScan Cloud, please contact us.