top of page
Writer's pictureCRM Science

Salesforce Logins for Continuous Integration and Delivery


Salesforce Logins for Continuous Integration and Continuous Delivery (CI/CD)

Continuous Integration and Continuous Delivery (CI/CD) are the processes used by development teams to help test and deliver code in the fastest and safest way possible.

When a developer is finished with his or her task, they commit their code to a version control system to share the rest of the team. When they do this, an automatic process on a different computer picks up their code and runs a variety of tests on it.

If the tests pass, then the new code gets the green light and is then distributed to the rest of the team or maybe even promoted to production. If any of the tests fail, the process shuts down and the developer is alerted of the issue with their new code.

Continuous Integration and Continuous Delivery in modern software development

Continuous Integration and Continuous Delivery in modern software development

CI and CD should be considered an essential part of modern software development, and Salesforce DX has been designed to allow developers to use most CI tools for Salesforce development.

The most common example of how this would work is having your automation process:

  1. Create a new scratch org

  2. Deploy the contents of your DX project to this new org

  3. Run all your apex tests

  4. Delete the org

This allows you to flag any potential issues with your DX code before you deploy to a sandbox or production.

Logging into your Salesforce Developer Hub org

Salesforce offers an excellent Trailhead module that reviews step-by-step how to use Salesforce DX with a CI/CD tool called Travis CI. But, there is one point in the tutorial where the process starts to get a little cumbersome — logging into your Developer Hub org.

The CI automation tools need to log into your Developer Hub org on your behalf to create a new scratch org. However, you do not want to store your Salesforce password anywhere it can be accessed by others. In fact, Salesforce never wants you to store your password in any system other than their own. That is why they have switched to OAuth for all their developer tools, including Salesforce DX.

Logging into your Salesforce Developer Hub Org

To log into your Developer Hub org for DX on your own computer, you must run the web authentication command in your command line:

$ sfdx force:auth:web:login -d -a Hub_Org

This command opens a web browser pointed to the Salesforce login page. You log into Salesforce with your username and password, and you click a confirmation button acknowledging that you wish to share your login with Salesforce