Loading
Prepare for Email to Become the Default Login ExperienceRead More
Salesforce Enforces New Security Requirements in Summer 2026Read More
Govern, Manage, and Release Changes with DevOps Center
Quick Start: Use Salesforce CLI with DevOps Center

Quick Start: Use Salesforce CLI with DevOps Center

Use Salesforce CLI to automate DevOps Center tasks from the command line. In this quick start, you create and activate a pipeline, manage a work item, and promote changes to the next pipeline stage.

Required Editions

Available in: Lightning Experience in Professional (API access required), Enterprise, Performance, Unlimited, and Developer Editions
Not available in: Government Cloud Plus. Contact your Salesforce account executive for more details.
Not available in: EU Operating Zone. EU Operating zone is a special paid offering that provides an enhanced level of data residency commitment. DevOps Center is supported in orgs in the EU that aren't part of EU OZ, per standard product terms and conditions.
User Permissions Needed
To create a pipeline: DevOps Center Admin
To promote changes through the pipeline: DevOps Center Deployment Manager

For all available flags and options, see Salesforce CLI Command Reference.

Before you begin, complete these tasks.

  • Install Salesforce CLI. See Install Salesforce CLI.
  • Install the DevOps Center plugin.
    sf plugins install @salesforce/plugin-devops-center
  • Authenticate to the org where DevOps Center is available. This quick start uses my-devops-org as the org alias.
    sf org login web --alias my-devops-org
  • Create a DevOps Center project from the UI.
  • Connect the GitHub (or Bitbucket) repository to your DevOps Center org.
  • Set the authenticated org as the default org.
    sf config set target-org=my-devops-org

    Setting the target org omits --target-org my-devops-org from subsequent commands. This quick start includes the flag in each command so that the target org is clear.

Set Up a Pipeline

Create a pipeline, add and configure its stages, activate the pipeline, and attach your project.

  1. List your projects to find the project ID.
    sf devops project list --target-org my-devops-org

    Copy the ID of the project that you want to attach to the pipeline. The examples in this quick start use 0Hn000000000001.

  2. Create an inactive pipeline and connect it to your repository.
    sf devops pipeline create --target-org my-devops-org --name "Release Pipeline" --repo https://github.com/myorg/myrepo

    Copy the pipeline ID from the command output. The examples in this quick start use 0XB000000000001.

    The pipeline remains inactive until you configure its stages and activate it.

    To create a repository while creating the pipeline, use --create-repo with --repo-type github|bitbucket.

  3. Add stages to your pipeline. A new pipeline includes a default final stage. Add each new stage before an existing stage by specifying that existing stage with --next-stage-id.

    For example, add an Integration stage.

    sf devops pipeline stage add --target-org my-devops-org --pipeline-id 0XB000000000001 --name "Integration" --next-stage-id 0Xc000000000001

    Copy the stage ID from the command output. The remaining examples use 0Xc000000000005 for the integration stage. Repeat the command for each additional stage, such as UAT.

    Tip
    Tip View your pipeline in the DevOps Center UI to get the stage IDs for subsequent commands. Or run sf devops pipeline get --pipeline-id 0XB000000000001.
  4. Configure each stage. Each stage requires a branch and an environment. Configure stages from right to left because the final stage must have a branch before you can configure the stages before it.

    Add a branch to the Integration stage. The --create-vcs-branch flag creates the branch in the repository if it doesn't exist.

    sf devops stage branch add --target-org my-devops-org --pipeline-id 0XB000000000001 --stage-id 0Xc000000000005 --branch-name integration --create-vcs-branch

    Add a sandbox environment to the stage.

    sf devops stage environment add --target-org my-devops-org --pipeline-id 0XB000000000001 --stage-id 0Xc000000000005 --environment-name Integration_Org --org-type Sandbox

    A browser window opens so that you can authenticate to the environment. Use --org-type Production for production orgs. In a headless environment, add --no-browser and follow the authentication instructions returned by the command.

    Repeat the branch and environment commands for every stage. Use the branch name, environment name, and org type appropriate for each stage.

  5. Activate the pipeline.
    Important
    Important You can't modify the pipeline stage after you promote changes through it. Make sure that all stages are configured correctly before you run this command.
    sf devops pipeline update --target-org my-devops-org --pipeline-id 0XB000000000001 --activate
  6. Attach your DevOps Center project to the pipeline.
    sf devops pipeline project add --target-org my-devops-org --pipeline-id 0XB000000000001 --project-id 0Hn000000000001
    The pipeline is ready. Create work items in the DevOps Center UI or run the sf devops work-item create command.

Manage a Work Item

Complete a development cycle by starting a work item, committing your changes, creating a review, and marking the work item ready to promote.

You can pass --work-item-id instead of --work-item-name in all work-item and review commands.

  1. Set the work item status to In Progress. DevOps Center creates a feature branch for the work item.
    sf devops work-item update --target-org my-devops-org --work-item-name WI-000042 --status "In Progress"
  2. Fetch the feature branch from the connected repository and check it out in your local project.
    git fetch origin
    git checkout WI-000042
  3. Retrieve changes from your development org. This example retrieves an Apex class from the org with the alias my-sandbox.
    sf project retrieve start --target-org my-sandbox --metadata ApexClass:MyNewClass
  4. Review the retrieved files, stage them, commit them, and push the feature branch.
    git status
    git add force-app
    git commit -am "Implement new feature"
    git push origin WI-000042

    Adjust the path passed to git add if your Salesforce DX project uses a different package directory.

  5. Create a change request (pull request) to merge the feature branch into the target branch.
    sf devops review create --target-org my-devops-org --work-item-name WI-000042
  6. Wait for your team to approve and merge the change request.
  7. Update the work item status to indicate that it's ready for promotion.
    sf devops work-item update --target-org my-devops-org --work-item-name WI-000042 --status "Ready to Promote"

Promote a Work Item

Promote the work item to the next pipeline stage. DevOps Center validates the promotion, runs the test suites configured for the target stage, and deploys the changes if the tests pass.

  1. Promote the work item, using the work item ID and the target stage ID.
    sf devops promote --target-org my-devops-org --work-item-id 0Wx000000000042 --target-stage-id 0Xc000000000002

    The command output includes a Request ID. Use it to check promotion status.

    Status: Completed
    Message: Work items successfully promoted to UAT.
    Request ID: a0B000000000001
    
    Promoted Work Items
    ───────────────────
    0Wx000000000042
  2. Use the request ID to check the promotion status.
    sf devops request status --target-org my-devops-org --request-token a0B000000000001

When the request status is completed, the work item is available in the target stage.

Common Tasks

Use these commands during your daily development workflow.

  1. Promote multiple work items to the same stage. Specify --work-item-id once for each work item.
    sf devops promote --target-org my-devops-org --work-item-id 0Wx000000000042 --work-item-id 0Wx000000000043 --target-stage-id 0Xc000000000002
  2. Deploy externally merged changes to a stage that's out of sync with DevOps Center.
    sf devops promotion complete --target-org my-devops-org --target-stage-id 0Xc000000000002

Advanced Use Cases

After completing the basic workflow, use these commands for promotions that require more control.

  • Custom promotions: Run sf devops work-item prepare to create the required branches and change requests, and then promote the work item.
  • Combine work items: Run sf devops work-item combine when multiple work items share metadata or have dependencies and must be promoted together.
  • Validate before you promote: Run sf devops promotion validate to check version control and object permissions without promoting the work items.
 
Loading
Salesforce Help | Article