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.

  1. Select your Salesforce project from the My Projects screen.

  2. 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.

  1. Select your Salesforce environment.

  2. Once you click on Authorize, it will redirect you to the Salesforce login page to validate your credentials.

  3. This triggers the project analysis and the project being added under your CodeScan organization.

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.

codescan.comparison.branches

Points to Note:

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:

-Dsonar.comparison.branch=... -Dsonar.comparison.base=...

Another way is via Autorabit-CodeScan integration.

The new properties sonar.comparison.branch and sonar.comparison.base are equivalents/aliases of these existing two: sonar.pullrequest.branch and sonar.pullrequest.base.

To test the new feature using sonar-scanner:

  1. 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>
  1. 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>

Managing 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

Rename the main branch

Give the main branch a new name and click on Rename.

Comparing Branches

  1. Select your Salesforce project from the My Projects page.

  2. 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.

  3. 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.

Important Note:

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.

Last updated