> For the complete CircleCI developer hub index, see [llms.txt](https://circleci.com/developer/llms.txt)

# circleci/salesforce-sfdx

Salesforce SF CLI integration for CircleCI. Easily create CI/CD pipelines for your Salesforce integrations.


## Commands

### auth

Authenticate with and configure the SF CLI after installation. This orb utilizes JWT-based authentication. You will need to create a connected app and provide a base64 encoded server key for authentication. Learn more: https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_auth_jwt_flow.htm


| Parameter | Type | Default | Description |
|---|---|---|---|
| `apiVersion` | string |  | The API version for a specific project or all projects. Normally, the Salesforce CLI assumes that you're using the same version of the CLI as the Dev Hub org. |
| `consumerKey` | env_var_name | SFDX_CONSUMER_KEY | The consumer key of the connected app for salesforce. Stored as an environment variable |
| `decryption_key` | env_var_name | DECRYPTION_KEY | Environment variable name for server.key decryption key, if available. |
| `defaultdevhubusername` | string | ${CIRCLE_PROJECT_REPONAME}-${CIRCLE_BRANCH} | The username of your Dev Hub org that the 'org create scratch' command defaults to. Used as alias. |
| `defaultusername` | string |  | The username for an org that all commands run against by default. |
| `instanceUrl` | string |  | The URL of the Salesforce instance that is hosting your org. |
| `jwtKey` | env_var_name | SFDX_JWT_KEY | Environment variable containing the base64 encoded private server key. |
| `server_key` | string |  | Path to encrypted server.key within the project, if available. |

### install

Install and configure the Salesforce "sf" cli utility giving access to the "sf" commands. Set parameters to automatically set the sf config values. Also able to be set via environment variables. Learn more: https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_dev_cli_config_values.htm


| Parameter | Type | Default | Description |
|---|---|---|---|
| `version` | string |  | By default, the latest version of the standalone CLI will be installed. To install via npm, supply a version tag such as "latest", "latest-rc", "nightly", "2.1.1", etc. |

### scratch_create

"Create a scratch Salesforce Org."


| Parameter | Type | Default | Description |
|---|---|---|---|
| `overrides` | string |  | Overrides for scratch organization. |
| `scratch_alias` | string |  | The alias of the scratch Org. |
| `scratch_config` | string |  | The scratch JSON definition. |

### scratch_delete

"Delete a scratch Salesforce Org."


| Parameter | Type | Default | Description |
|---|---|---|---|
| `scratch_alias` | string |  | The name of the scratch Org, can either be the alias or target username. |

### scratch_open

"Open a scratch Salesforce Org."


| Parameter | Type | Default | Description |
|---|---|---|---|
| `scratch_alias` | string |  | The name of the scratch Org, can either be the alias or target username. |

## Executors

### default

This is a sample executor using Docker and Node. If you want to provide a custom environment in your orb, insert your image here. If you do not require an executor, you can simply delete this directory.


| Parameter | Type | Default | Description |
|---|---|---|---|
| `tag` | string | lts | Pick a specific circleci/node image variant: https://hub.docker.com/r/cimg/node/tags
 |

## Examples

### create_open_delete_scratch

Create, open, and then delete a scratch org.


```yaml
version: '2.1'
orbs:
  sfdx: circleci/salesforce-sfdx@x.y
jobs:
  create-open-delete:
    executor: sfdx/default
    steps:
      - checkout
      - sfdx/install
      - sfdx/auth:
          defaultusername: user@email.com
      - sfdx/scratch_create:
          scratch_alias: circleci
          scratch_config: ./config/project-scratch-def.json
      - sfdx/scratch_open:
          scratch_alias: circleci
      - sfdx/scratch_delete:
          scratch_alias: circleci
workflows:
  basic-test:
    jobs:
      - create-open-delete
```

### install_and_authenticate

Simple example showing how to install the Salesforce sf CLI with the default options and authenticate against it with JWT.


```yaml
version: '2.1'
orbs:
  sfdx: circleci/salesforce-sfdx@x.y
jobs:
  install_authenticate:
    executor: sfdx/default
    steps:
      - checkout
      - sfdx/install
      - sfdx/auth:
          defaultusername: user@email.com
      - run:
          command: >
            echo You now have access to the sf cli and may execute commands
            against it.

            sf auth list
          name: Run your SF commands here
workflows:
  basic-test:
    jobs:
      - install_authenticate
```