@borngroup/born-sfcc-ci
v2.2.1
Published
BORN Group's CI/CD tooling for Salesforce Commerce Cloud
Downloads
674
Readme
BORN SFCC CI
The BORN SFCC CI is a command-line interface to interact with your project's Commerce Cloud instances. It provides functionality to facilitate CI/CD practices. This project wraps Salesforce Commerce Cloud's CLI, the B2C Commerce Developer Sandbox REST API (DOC), and OCAPI.
Getting Started
In order to perform CLI commands, you have to permit API calls to your Commerce Cloud instances. There are three steps required:
- Set up a Commerce Cloud API key through Account Manager (or contact the technical admins on your project for existing API client credentials)
- Configure Open Commerce API Settings
- Configure WebDAV Client Permissions
Please see SFCC-CI: How do I get set up? for up to date environment setup steps.
Installation and Project Setup
Install the NPM package
BORN SFCC CI is an NPM package. It can be installed with the command:
npm install @borngroup/born-sfcc-ci --save-dev
NOTE: For Windows users, one additional step is required -- since born-sfcc-ci
is installed locally, you'll need to add path\to\project\node_modules\.bin
to the PATH environment variable in order to execute it without specifying the full path. Alternatively, you can install it globally with npm install -g @borngroup/born-sfcc-ci
.
Configurations
Configurations can be done in one of three places:
- In environment variables
- In a dw.json file
- As command line arguments
The list above is in order of precedence. For example, if the same configuration exists in both environment variables, as well as in dw.json, then dw.json will take precedence over the environment variable. If a configuration exists in both dw.json, and was passed in as a CLI argument, the CLI argument will take precedence.
Here is a table showing the key or property name in each of the three modes of configuration:
| Environment Variable | dw.json file | CLI Argument | | --------------------------- | -------------- | ---------------- | | BORN_SFCC_CI_CLIENT_ID | client-id | --client-id | | BORN_SFCC_CI_CLIENT_SECRET | client-secret | --client-secret | | BORN_SFCC_CI_HOSTNAME | hostname | --hostname | | BORN_SFCC_CI_VERSION | version | --code-version | | BORN_SFCC_CI_DATA_BUNDLE | data-bundle | --data-bundle | | BORN_SFCC_CI_DATA_HOSTNAMES | data-hostnames | --data-hostnames | | BORN_SFCC_CI_CODE_HOSTNAMES | code-hostnames | --code-hostnames |
Create a dw.json
BORN SFCC CI supports a valid dw.json in the root directory. This is the most common mode of configuring the tool for developers. The dw.json provides the credentials and environmental setting needed to issue commands against your Commerce Cloud instances.
dw.json
{
"username": "[email protected]",
"password": "account-manager-password!123",
"client-id": "project-cicd-client-id",
"client-secret": "project-cicd-client-secret",
"hostname": "my-instance.sandbox.us01.dx.commercecloud.salesforce.com",
"version": "myversion",
"data-bundle": "sandbox",
"data-hostnames": ["my-instance01.com", "my-instance02.com"], // added for usage by the technical lead; can be omitted by developers.
"code-hostnames": ["my-instance01.com", "my-instance02.com"] // added for usage by the technical lead; can be omitted by developers.
}
dw.json properties
- username: Your SFCC Account Manager username. This is required.
- password: Your SFCC Account Manager password. This is required
- client-id: A valid Commerce Cloud API client id which will be provided by a technical admin (most likely the TL of your project). This is required for code activation and data deployment.
- client-secret: A valid Commerce Cloud API client secret which will be provided by an technical admin (most likely the TL of your project). This is required for code activation and data deployment.
- hostname: The hostname of your Commerce Cloud instance. This is required. Always pass the non-cert hostname, even when deploying to staging.
- version: Your code version. Typically, your first initial + last name i.e., jdoe. This is required for code activation and upload.
- data-bundle: A data bundle to deploy. The available data bundles are defined in site_data/config.json. Each bundle references a set of data directories to upload and import into your instance. This is required for data deployment.
- data-hostnames: An array of hostnames pointing to Commerce Cloud instances. This allows deployment of data to multiple instances at once. This is an optional property for TL usage and should be removed to avoid accidental data deployments to other sandoxes than your own. When it is present, it will take precedence over the
hostname
property. - code-hostnames: An array of hostnames pointing to Commerce Cloud instances. This allows deployment of data to multiple instances at once. This is an optional property for TL usage and should be removed to avoid accidental data deployments to other sandoxes than your own. When it is present, it will take precedence over the
hostname
property.
Configure site_data
BORN SFCC CI uses the site_data directory in the root directory for data deployment.
See https://bitbucket.org/borngroup/sfcc-accelerators/src/master/site_template/readme.md
Usage
Invoke the help command for up to date usage information
born-sfcc-ci help
born-sfcc-ci help <command>
Tasks
Activate Code
Activate a code version specified in your configurations on your Commerce Cloud instance. This can be useful when beginning development to ensure your code version is active.
born-sfcc-ci activate-code
Clear Auth Token
Deletes the locally cached auth token. Useful for after changing credentials.
born-sfcc-ci clear-auth-token
Deploy Code
Compress and upload a set of cartridges to your Commerce Cloud instance. It uploads all cartridges within the /cartridges directory. This action also checks the B2C Instance for an old code version with the same name. If that exists, it will delete it prior to upload.
born-sfcc-ci deploy-code
Deploy Data
Compress, upload, and import a set of data archives to your Commerce Cloud instance. Using the data-bundle
property, this command identifies and deploys the corresponding data folders in the site_data/config.json file.
born-sfcc-ci deploy-data