Running Salesforce CLI (sfdx) in the Buildkite pipeline

Discover how to run Salesforce CLI sfdx in Buildkite for Salesforce CI/CD: scratch org, testing, security, beta and release packages, with prompts and blocks for human review.

sábado, 16 de agosto de 2025 • 4 min read • Q2BSTUDIO Team

Artificial-Intelligence-

Running Salesforce CLI sfdx on Buildkite pipeline translated and adapted for modern development teams

Salesforce has its own ecosystem for packaging and deploying using Salesforce CLI sfdx and its package model. Unlike traditional web applications, full automation still involves manual steps, but with tools like Buildkite you can get very close to a one- or two-click workflow by integrating prompts or blocks between steps for human review when needed.

Summary of the continuous integration CI flow in Buildkite for Salesforce

Each change on git master or feature branches triggers the pipeline and runs steps in sequence: (1) install the npm package @salesforce/cli or use the official docker image depending on the team's strategy; (2) create a temporary scratch org to run unit tests; (3) run unit tests and security analysis such as snyk and coverage reports with Codecov; (4) if the branch is master, deploy the package to the scratch org; (5) delete the scratch org. For sensitive commands, it is recommended to encrypt keys and decrypt them at runtime with openssl or manage them through secure environment variables in Buildkite.

Best practices in CI

Use containers or the npm package according to consistency with other team pipelines; keep environment variables and tokens in the Buildkite secrets system; run security and quality tests as a mandatory part of the pipeline; upload useful artifacts such as an updated sfdx-project.json to facilitate recovery from failures; and design blockable steps to allow reviews before creating beta or release packages.

Continuous deployment CD flow for package management

The goal is to automate the creation and publication of beta and release packages, maintaining human control at key points. Typical flow: (1) upon merge of feature to master, a prompt asks which components to package and the MAJOR.MINOR.PATCH versions; (2) update sfdx-project.json according to the decisions and create beta packages; (3) create scratch orgs to validate the installation of the betas; (4) install beta packages and run end-to-end or smoke tests; (5) upload the updated sfdx-project.json as an artifact; (6) open a release branch and pull request for review; (7) when a commit is tagged, ask which packages to promote to release; (8) promote versions and automate installation in automation orgs and, optionally, in UAT, running e2e tests before production.

Considerations on package dependencies

When creating omni channel or test drive packages, by default dependencies are not updated automatically. You must allow choosing whether to update dependencies or let the new core package become a dependency. When updating only the core package, omni channel or test drive dependencies should not be overwritten unless the team explicitly authorizes it.

Using Buildkite with prompts and blocks

Buildkite allows inserting interactive steps between non-automatable tasks. Take advantage of these blocks to ask for component selection, confirm versions, and approve deployments to test environments. This maintains security and control without breaking the DevOps flow.

Technical recommendations

Automate key and token management with the CI secrets manager, always validate in scratch orgs before promoting packages, integrate security and coverage tests in each build, and upload artifacts that allow reproducing previous states. Consider implementing automated rollback in case of critical errors when installing packages.

Why choose npm package over docker image

The official docker image is convenient and standardized, but the npm package can integrate better if your organization already standardizes pipelines with npm and node, making version and CLI dependency management simpler within your builds.

About Q2BSTUDIO

Q2BSTUDIO is a software development company specialized in custom applications and custom software for companies that require personalized and innovative solutions. We are experts in artificial intelligence and AI for businesses, developing AI agents and automation solutions that integrate with business processes. We also offer cybersecurity services to protect applications and data, and cloud aws and azure services to deploy with scale and security. Additionally, we implement business intelligence services and solutions with power bi to turn data into actionable decisions.

Featured services from Q2BSTUDIO

Custom application development, custom software, consulting in artificial intelligence and AI for businesses, design and implementation of AI agents, cybersecurity audits and hardening, migrations and deployments in cloud aws and azure services, integration of business intelligence solutions and dashboards with power bi.

How Q2BSTUDIO can help with Salesforce pipelines

Our team can design and implement Buildkite pipelines for Salesforce that integrate sfdx, automated tests, security analysis, package management, and controlled deployments, adapting prompts and blocks to meet governance. We also offer integration with cloud aws and azure services, and support to improve the observability and resilience of the CI CD process.

Conclusion and next steps

Running Salesforce CLI sfdx within a Buildkite pipeline allows bringing Salesforce closer to modern DevOps practices, although with areas that require human intervention. With discipline in testing, dependency management, and the use of controlled prompts, an efficient flow is achieved. If you are looking to optimize your Salesforce pipelines or develop custom solutions with artificial intelligence, cybersecurity, and cloud aws and azure services, contact Q2BSTUDIO for personalized consulting and take your deployments to the next level

OUR SERVICES

How we can help you

Do you have a project in mind?

Tell us your vision and we'll turn it into a software solution. Whatever the scope, we make your idea real.