Skip to content

CLI Reference

glassops is one Go binary that runs each delivery step as its own command. The goal is a governed pipeline that runs the same way in any CI system or on a laptop. Salesforce is the first provider.


Commands

Command What it does
glassops init Detects the provider and the CI system, then writes glassops.yaml and a CI file
glassops doctor Checks the config, the tools, the git checkout and the environment variables the config names. With --auth it also logs in to targets
glassops describe Logs in to one target, runs the guard, and records what the target reports about itself
glassops plan Works out what changed between two git refs and writes the manifests and a change set
glassops validate Runs a check-only validate of the change set against a target
glassops gate Evaluates the policy rules for a target and writes a signed PERMIT
glassops permit verify Checks that a PERMIT is signed, unexpired and bound to this target, commit, plan and config
glassops deploy Deploys the change set to a target, only under a valid PERMIT
glassops verify After a deploy, checks that the target holds what the plan says
glassops report Summarises every result for the CI and writes SARIF
glassops env create Creates the ephemeral environment (a scratch org) that later steps use
glassops env delete Deletes that environment
glassops env sweep Deletes old environments that a cancelled run left behind
glassops test Runs Apex tests with coverage on a target and writes JUnit XML
glassops run Runs a whole pipeline from glassops.yaml
glassops check Runs your own project scripts
glassops analyze Runs the Code Analyzer and records the violation counts
glassops op Runs one operation that gate --ops has already allowed
glassops setup Installs the sf plugins tools.sf.plugins lists, with no login

glassops init

  • Detects a Salesforce project from sfdx-project.json.
  • Detects the CI system from the project files (.github, bitbucket-pipelines.yml, .gitlab-ci.yml, azure-pipelines.yml) or from the environment it runs in.
  • Writes glassops.yaml with commented stub targets and the default pr and deploy pipelines.
  • For GitHub, also writes .github/workflows/glassops.yml, which runs glassops doctor on full git history. Other CI systems are detected but get no CI file yet.
  • Never overwrites a file unless you pass --force.
  • Does not touch .gitignore. Add .glassops/ to it yourself. That directory holds the plan, the PERMIT, the results and the deployed-tag bookkeeping, and none of it belongs in git. Run git status after your first command to see it appear.

glassops doctor

Runs these checks and fails if any of them fails:

  • glassops.yaml, when present, against the schema and its rules. Without the file, the defaults are used.
  • The provider: the config and the project files must agree.
  • The tools: git always, plus sf and the sfdx-git-delta plugin for Salesforce projects. Versions are recorded.
  • The sf plugins under tools.sf.plugins, only when the config lists any: one plugin.<name> check each, which fails when the plugin is missing or at another version than the config's. The installed versions are the fact tools.sf.plugins. Run glassops setup to install them.
  • The analyzer, only when analyze.enabled is true: Java 11 or newer and the Code Analyzer plugin (tool.java and tool.code-analyzer). Both are in the glassops-analyzer image.
  • Opt-in features, only when you turn them on: cosign and the signing identity, issuer and repository for Sigstore signing, and opa and the policy files for Rego rules.
  • The checkout: a shallow clone fails, because it would make every change set empty. On GitHub, use actions/checkout with fetch-depth: 0.
  • The environment: every $VAR the config names must be set. Only presence is checked. Values are never printed or stored.
  • The PERMIT key: on a pull_request or pull_request_target run, GLASSOPS_PERMIT_KEY should not be set. If it is, doctor adds a permit.key check whose detail starts with warning: and a CI warning annotation. This never fails the command. Only presence is checked. See PERMIT and rules.

glassops doctor --auth

Adds a login to each target in the config, or only the one named by --target, and runs the guard on it. A target with named logins gets one more check for each, named auth.<target>.<login>, with the same login and guard run against the same org Id as the target. A login that fails or reaches another org is an error. Without --auth, doctor never logs in. The environment check covers every $VAR the config names. With --auth --target, it covers only that target's variables, so a target that does not exist yet, such as a scratch org that a later step creates, does not fail the check.

Flag Meaning
--auth Also log in to targets and run the guard
--target With --auth, check only this target

glassops describe

Logs in to one target, runs the guard, and writes what the target reports about itself to .glassops/results/describe.json. A guard mismatch exits 2 before anything else runs.

Flag Meaning
--target Target name from glassops.yaml (required)

glassops plan

Works out the change set between two git refs. It writes the provider's manifests to .glassops/plan/ and the change set to .glassops/plan.json. For Salesforce, sfdx-git-delta works out the delta and the project's .forceignore applies. A shallow clone is an error, never an empty plan. For Salesforce, plan also reads the checked out source of each changed Apex class and records the classes annotated @IsTest in the fact salesforce.apex_test_classes, and the classes whose top level type is an interface or enum, which have no executable lines and no coverage, in the fact salesforce.apex_nonexecutable_types. The check looks at the annotations before the first class keyword, after it strips comments and strings. It is not an Apex parser, and a class it cannot read is treated as a normal class. With a full scope, plan lists the whole source instead, and it reads no git history. See the plan scope below.

Flag Default Meaning
--from auto Base git ref, or auto
--to auto Head git ref, or auto (HEAD)
--target Target the plan is for, used by --from auto and the plan scope. A name under targets or environments
--scope full or delta. Overrides the config for this run

With --from auto, a pull request uses the merge base with its base branch. With --target, auto uses the git tag glassops/deployed/<target>, then the merge base with the target's branch. Without either, pass --from.

On a laptop, outside a pull request, there is no base: --from auto without --target stops with "--from auto needs a target or a pull request base branch. Pass --from." For a first run, name the base yourself:

glassops plan --from HEAD~1

First deploy rule: with --target and --from auto, a target that has no glassops/deployed/<target> tag has never received a deploy from glassops. plan then plans the whole source instead of a delta, prints a notice, and records the facts plan.first_deploy and plan.from_source: first-deploy. A shallow clone is still an error.

Plan scope: full plans the whole source and delta plans what changed. plan takes the first of these that is set: --scope, then targets.<target>.plan.scope for the --target given, then salesforce.delta.enabled, then delta. A full scope never looks up a tag or a merge base, so a shallow clone does not matter. A delta scope still follows the first deploy rule. Use scope: full on a scratch org target, where a delta would fail on components the empty org does not have, and keep production on delta. plan records the facts plan.scope and plan.scope_source, and doctor prints the scope every target gets.

glassops validate

Logs in to the target, runs the guard, and runs a check-only validate of the change set in .glassops/plan.json. It never deploys. See Validate is check-only.

Flag Default Meaning
--target Target name from glassops.yaml (required)
--fallback-target Target to use when --target is not configured or not reachable
--plan <dir>/.glassops/plan.json Change set file
--check-only true Always true. false is refused

A target counts as not configured when it is missing from glassops.yaml or when its id variable is not set, for example because the scratch org was never created. A guard mismatch never falls back. The test level comes from salesforce.test_level for the tier of the target used, then its default entry, then the Salesforce CLI's own default. An empty change set ends with status empty and no login. When the Salesforce CLI stops watching a validate that is still running, for example because its wait ran out, validate waits on sf project deploy report until the org gives the final status, so a validate still in progress is never read as a failure. validate records the facts validate.plan_sha256, validate.change_set_sha256 (the hash a PERMIT binds the change set by) and validate.test_level, which gate uses to decide whether a deploy may reuse the validation. See validation binding.

glassops gate

Reads the change set, the earlier results in the results directory and the CI context. It builds the facts for one target, runs the policy rules over them, and writes a signed PERMIT to .glassops/permit.json. It writes the PERMIT whether the answer is allow or deny, and it deletes any PERMIT already at that path first, so an old allow never survives a failed run. Unless --no-connect is set, it logs in to the target and runs the guard. The rules, the PERMIT and the evidence gate reads are described in PERMIT and rules.

Flag Default Meaning
--target Target name from glassops.yaml. Required unless --ops is given
--ops Operation names from operations in glassops.yaml, comma separated or repeated. Makes an operations PERMIT with no plan. See below
--param With --ops only. A value for an operation param, as <operation>.<param>=<value>, or <param>=<value> when --ops names one operation. Repeat it for each param. The PERMIT records the value
--plan <dir>/.glassops/plan.json Change set file
--permit <dir>/.glassops/permit.json Where the PERMIT is written
--no-connect false Do not log in. The PERMIT records the configured Id and the kind the guard would require, from the tier or from targets.<name>.kind, with kind_source set to declared. With neither, the kind is unknown. The guard check is skipped
--deploy-command Provider exec only. The command deploy -- will run, as a JSON array of strings, such as '["./deploy.sh","--prod"]'. The PERMIT binds its SHA-256, never the text. With any other provider it is an error
--exec-command The run text of a pipeline exec step that may run logged in to this target, exactly as written. Repeat it for each step. The PERMIT binds the SHA-256 of each, never the text. See exec steps with a target

When the target's tier has deploy windows and the gate's clock is inside one, the PERMIT expires when that window closes, if that is before policy.permit_ttl. Windows that overlap or touch extend it. With no window for the tier, or a clock outside them, the PERMIT keeps the full TTL, and the window rule decides.

A blackout shortens the PERMIT too. When a blackout that covers the target's tier has not ended by today (UTC), the PERMIT expires when it begins, at 00:00 UTC on its first day, if that is before the TTL and before any window end. A PERMIT issued before a blackout can never be valid inside it. An ephemeral target is not checked against blackouts, so its PERMIT is not shortened. deploy needs no separate blackout check, because the config is bound by hash and the expiry is checked at deploy.

gate --ops. A mode of gate for production commands that are not a deploy, such as a heartbeat query or a cache refresh. glassops gate --ops heartbeat,unfreeze-owner issues one PERMIT, of kind operations, for the named operations. It needs no plan, and the PERMIT binds the SHA-256 of each operation's run text in exec_commands_sha256. The operations must be declared under operations in the glassops.yaml at the commit being run, and must all be on one target. --target is optional with --ops, and when given it must be that target. --ops cannot be combined with --plan, --deploy-command or --exec-command. It logs in to the target with its default login and runs the guard, unless --no-connect is set. Then:

  1. The run must be on the default branch. On GitHub Actions the default branch is repository.default_branch in the event payload file (GITHUB_EVENT_PATH), which needs no API call. On GitLab it is CI_DEFAULT_BRANCH. Anywhere else, or when the CI reports none, it is policy.operations.branch, which defaults to main. A pull request, a tag or another branch is denied.
  2. Git HEAD must be the run's commit and no tracked file may be modified, the same tree check deploy makes. glassops.yaml must be committed.
  3. The rules plan_not_empty, coverage_min, destructive_needs_label, analyzer_max_severity and validate_passed are recorded as skipped with the detail operations PERMIT, no plan. The blackout rule runs unless policy.operations.blackout is false. The window rule runs only when policy.operations.window is true.
  4. Separation of duties. When every named operation has schedule_ok: true, the reviewed config on the default branch is the approval. The PERMIT records separation_of_duties.mode as reviewed_config, with the mechanism config_commit:<sha>, the commit that last changed glassops.yaml. An operation without schedule_ok needs the same approval evidence a deploy needs, so policy.rules.separation_of_duties applies to it.
  5. The PERMIT lives policy.operations.ttl (default 15 minutes), shortened to a blackout start when the blackout rule applies and to the window end when the window rule applies. It is signed with policy.operations.signing when that is set, else with policy.permit.signing.

Params. An operation whose run is a list may take params. gate --ops publish-site --param publish-site.site=Portfolio gives one value, and --param site=Portfolio is the same when --ops names one operation. A param with no --param takes its default. Before any rule runs or any login, each value is checked against its limits, and a file value must be a file tracked in git at the run's commit whose working copy is that blob. A bad or missing value, an unknown param, a value for a string run and a value given twice are exit 2 and write no PERMIT. The PERMIT records each value under operation_params, with the blob of a file value, and binds the argument list the values make. Its checks hold one command.<operation> result per list run that shows that argument list, so the PERMIT, permit verify and the report show exactly what will run.

A target of tier ephemeral is refused, because operations are for long lived orgs. A name that is not declared, operations on different targets and a flag that belongs to a plan based gate are exit 2 and write no PERMIT. A run off the default branch, a modified tree, a blackout or a failed guard write a signed PERMIT that denies, with exit 1. deploy refuses an operations PERMIT by name before it logs in. See Operations PERMIT.

Needs GLASSOPS_PERMIT_KEY, unless policy.permit.signing is sigstore. Then it needs a GitHub Actions job with id-token: write and cosign instead, see Sigstore signing. With policy.rego set it also runs your Rego rules with opa. Reads .glassops/plan.json, .glassops/results/plan.json and .glassops/results/validate.json when they exist, and the CI context. Writes .glassops/permit.json, .glassops/facts.json and .glassops/results/gate.json.

Exit When
0 The PERMIT allows the deploy
1 Policy denies the deploy. The signed PERMIT is still written
2 GLASSOPS_PERMIT_KEY is missing or unusable, the plan file is missing or unreadable, the target is not in the config, or evidence could not be gathered. A missing key, plan or target writes no PERMIT. Evidence that could not be gathered writes a signed PERMIT that denies. With --ops, an operation that is not declared, operations on different targets, a tier ephemeral target, a plan flag and a bad or missing --param value also exit 2 and write no PERMIT. --param without --ops exits 2

Result facts: gate.allow, gate.ephemeral, gate.permit_id, gate.expires_at, gate.expires_at_window_end (true when the window end set the expiry), gate.expires_at_blackout_start (true when a blackout start set the expiry), gate.deploy_command_sha256 when --deploy-command was given, and gate.exec_commands_sha256 when --exec-command or --ops was given. With --ops there are also gate.kind (operations), gate.operations and, when any operation takes params, gate.operation_params (the values by operation and param). The facts document carries permit.kind (deploy or operations) and one permit.params.<operation>.<param> fact per value, which a Rego rule can read.

glassops permit verify

Checks a PERMIT without logging in to the target, so any deploy tool can honour it. It checks the key, the signature, that the PERMIT allows, that it has not expired, that its lifetime is sound, and that it matches the target, the commit, the plan, the change set and the config. The order is in PERMIT and rules.

Flag Default Meaning
--target Target name from glassops.yaml (required)
--permit <dir>/.glassops/permit.json PERMIT file
--plan <dir>/.glassops/plan.json Change set file
--deploy-command Provider exec only. The command deploy -- is about to run, as the same JSON array of strings gate --deploy-command takes. The PERMIT must bind exactly this command. With any other provider it is an error

Without --deploy-command the command is not checked, as deploy without -- does not check it. With it, a PERMIT that binds no command, or another one, fails (exit 1).

Needs GLASSOPS_PERMIT_KEY, unless policy.permit.signing is sigstore. Then it needs cosign and a pinned repository instead, see Sigstore signing. Reads the PERMIT, the change set, the plan files under .glassops/plan/, glassops.yaml and the CI commit. Writes .glassops/results/permit-verify.json.

Exit When
0 The PERMIT holds
1 The PERMIT does not hold: bad signature, denied, expired, a different target, commit, plan, config, change set or deploy command, a file that is not a readable PERMIT, or plan files changed after plan
2 The key is missing or unusable, or the PERMIT file, the change set, the config or the commit cannot be read or found, or --deploy-command is not a JSON array of at least one string or is used with a provider other than exec

Result facts: permit.key_id, permit.id and permit.expires_at.

For an operations PERMIT it reads no plan. It checks that each operation the PERMIT lists is still declared on this target, and rebuilds each command from the config and the values the PERMIT records, so a changed template or a value that no longer fits its limits fails. The permit check shows each operation's values and argument list, and the fact permit.params holds the values.

glassops deploy

Verifies the PERMIT before it logs in. Then it runs the guard and deploys the change set in .glassops/plan.json. When the PERMIT holds a validated deploy Id, it quick deploys that validation. See validation binding. Success is read from the target's result body. After a successful deploy it moves the git tag glassops/deployed/<target> to the deployed commit and pushes it. The tag is lightweight. A failed move or push is a warning, because the deploy has already happened: the tag check is skipped, deploy.tag_pushed is false, and the CI gets a warning annotation. A checkout with no remote called origin gets that warning too, never a failure. A target of tier ephemeral keeps no tag, because its org does not outlive the run. deploy then moves and pushes nothing, the tag check is skipped with no warning, and deploy.tag_pushed is false.

The local tag stays. The tag is moved in your checkout before the push, so it stays there when the push fails. A rerun of plan --target <target> then starts from the deployed commit and finds nothing to deploy. If the push did not happen and you want the plan to start from the old base again, delete the local tag:

git tag -d glassops/deployed/prod

A deploy the target reports as failed lists one problem line per component failure, per test failure and, when the status is not Succeeded, per coverage warning.

Flag Default Meaning
--target Target name from glassops.yaml (required)
--plan <dir>/.glassops/plan.json Change set file
--permit <dir>/.glassops/permit.json PERMIT file
--wait the provider's How long to wait for the deploy, such as 30m. The Salesforce provider waits 60 minutes
--resume Job Id of an earlier deploy to wait on again. Skips quick deploy. Accepted only when .glassops/results/deploy.json records that job timing out under the same PERMIT and target

With provider exec, a command after -- runs instead of exec.deploy: glassops deploy --target prod -- ./ci/deploy.sh. See the exec provider. A command after -- with any other provider is an error.

Needs GLASSOPS_PERMIT_KEY and a git checkout. The deployed commit is the CI's commit, or git rev-parse HEAD when the CI reports none. It must be the commit the PERMIT names. After the PERMIT verifies and before the login, git rev-parse HEAD must also be that commit and no tracked file may be modified or staged. Untracked files are allowed. With provider exec, a command after -- runs only when the PERMIT binds exactly that command, from gate --deploy-command. An empty change set under a valid PERMIT ends with status empty and no login.

Exit When
0 The deploy succeeded, or the change set was empty
1 The deploy ran and the target reported failures, or salesforce.deploy.quick is require and the PERMIT holds no passed validation to quick deploy
2 The PERMIT is missing, unreadable, denied, expired or does not match, the plan files changed, the working tree is not the PERMIT's commit or git cannot tell, --resume names a job the last deploy did not time out on, login or the guard failed, or the deploy did not finish within --wait. A timeout keeps the job Id and prints the --resume command, and does not move the tag

Result facts: deploy.permit_id, deploy.plan_sha256, deploy.test_level, deploy.quick_mode, deploy.id, deploy.quick, deploy.timed_out, deploy.commit, deploy.tag and deploy.tag_pushed, plus the provider's own facts. deploy.plan_sha256 is the plan the deploy sent. deploy.test_level is the level the deploy was sent with, or for a quick deploy the level of the validation it reused.

glassops verify

Runs after deploy and checks that the target holds what the plan says. It never deploys. It is the last step of the default deploy pipeline, before report.

Before it logs in, verify reads the deploy result and the change set. It stops with an error when the deploy result is for another target or provider, did not pass, did not finish (a timeout), or has no deploy Id, because there is no finished deploy to check. It checks that the plan files still match the plan digest. deploy always records deploy.plan_sha256 and deploy.test_level, so verify always ties the plan to the deploy: the recorded digest must equal the plan's digest, and the fact verify.plan_bound_to_deploy is true. It is false only for a deploy result deploy did not write. An empty deploy ends verify with status empty and no login. Then it logs in, runs the guard, and the provider runs these checks:

Check Passes when
verify.status The target's deploy record says the deploy succeeded. A failed deploy lists the coverage warnings the report holds
verify.check_only The deploy was not a check-only run, so it changed something
verify.members Every component in the plan, and every destructive member, is in the deploy's component successes. Counts are recorded as facts and never compared, because the target's counts expand and vary
verify.tests Apex tests ran when the test level needs them. A quick deploy and an empty test level skip this check. At RunRelevantTests, a plan with no Apex class or trigger may run no tests, and the check is skipped then
verify.flows Every Flow in the plan whose source says Active runs as its latest version in the target, and when the deploy changed it, that version was modified after the deploy started. A Flow whose source says Draft is not checked
verify.foreign_deploys No other deploy that is not check-only was created in the target between the deploy's start and now. Fails or warns according to the setting
verify.smoke The verify.smoke command exits 0. Skipped when it is not set

Anything the provider cannot read, such as a query that fails, is an error and never a pass. A warning is a passing check whose detail starts with warning:. It adds a CI warning annotation and its name to the fact verify.warnings. The smoke command runs even when an earlier check failed, but not after the provider returned an error.

Settings verify.smoke, verify.foreign_deploys and verify.flows are in Verify, coverage and YAML settings. With provider exec, the provider runs exec.verify instead of the checks above. See the exec provider.

Flag Default Meaning
--target Target name from glassops.yaml (required)
--plan <dir>/.glassops/plan.json Change set file
--deploy-result <results-dir>/deploy.json Deploy result to verify

Reads the deploy result, the change set and the plan files. Writes .glassops/results/verify.json.

Exit When
0 Every check passed. Warnings still exit 0
1 A check failed
2 A tool error: the deploy result or the change set cannot be read or does not match, login or the guard failed, or the provider could not read the target

Result facts: verify.passed, verify.deploy_id, verify.deploy_quick, verify.commit, verify.permit_id, verify.plan_sha256, verify.plan_bound_to_deploy, verify.warnings and verify.smoke_exit_code, plus the provider's own facts.

glassops report

Reads every result in the results directory. It writes a markdown summary to the CI's run summary, and with --summary also to a file. It writes SARIF to --sarif for policy denials found in the PERMIT and for failed checks in the validate and deploy results. SARIF files already in the results directory, such as Code Analyzer's, are merged into the output. The SARIF file it writes is skipped when it reads the directory again. report writes no result file of its own.

Flag Default Meaning
--sarif <dir>/.glassops/report.sarif SARIF file to write
--summary Also write the markdown summary to this file
--pr-comment false On a GitHub pull request run, also post the summary as one pull request comment, created the first time and updated after. report.pr_comment: true does the same. A failed post only warns. See Pull request comment

report exits with the worst status among the results: 0 when all pass, 1 when any failed, 2 when any errored. That lets a CI run it after a failed step with if: always() and still fail the job. It also exits 2 when there are no results or one cannot be read.

glassops env create

Creates the ephemeral environment named under environments in glassops.yaml, from its Dev Hub target, for later steps to use. It logs in to the hub and runs the guard on it. The default pr pipeline runs it before validate.

For Salesforce it does not run sf org create scratch. It creates a ScratchOrgInfo record in the Dev Hub (a signup), polls until the record is Active for up to 15 minutes, and exchanges the record's auth code for a login. A signup refused for capacity or a transient error is retried up to three times. A signup that is still not active after 15 minutes is not retried, because it could still become active. The scratch definition file (environments.<target>.definition) supports the keys edition, features, hasSampleData, language, country, description, release and sourceOrg. Any other key, including settings, is an error, so an org is never created without something the file asks for. orgName is replaced by the environment name.

Flag Default Meaning
--target ephemeral Environment name from the environments section
--name <prefix>-<repo>-<pr or branch>-<run> Environment name. The prefix is environments.<target>.prefix, default glassops. Outside CI the repo is the project directory and the run is a UTC timestamp
--ttl-days environments.<target>.ttl_days, else 1 Days the environment lives
--shape environments.<target>.shape Source org Id for an org shape. A $VAR is read from the environment
--env-file <dir>/.glassops/env/<target>/env.json Where to write env.json

How later steps use the org. env create writes env.json and a login file. env.json records the environment name, Id, expiry and the path of the login file, and holds no secret. The login file holds an sfdx-url login, is readable only by the current user, and lives in the operating system's temporary directory. When each command runs in its own container, set TMPDIR to a mount they share. A later command that resolves a target named under environments, such as validate --target ephemeral, finds env.json and logs in with that file instead of the $VAR settings. With no env.json, the target falls back to its targets entry, and --fallback-target applies if that is not configured. An env.json that records a failed create (ready: false) counts as not configured. On GitHub, env create also sets the step outputs env_id, env_file and auth_file.

Dev Hub reserve. When environments.<target>.reserve is set, env create reads the hub's limits once, after the login and the guard and before it creates anything. For Salesforce that is one sf org list limits call, which counts as one API request. It refuses, and creates nothing, when DailyApiRequests remaining is below the reserve, when DailyScratchOrgs or ActiveScratchOrgs has none left, or when the hub refuses the read because its daily API cap is spent. The refusal is the check reserve, with status fail, and the result facts env.reserve.api_remaining, env.reserve.api_max, env.reserve.api_reserve, env.reserve.scratch_daily_remaining, env.reserve.scratch_daily_max, env.reserve.scratch_active_remaining and env.reserve.scratch_active_max. They are counts only. A limits read that fails for another reason, or whose answer lacks one of the three figures, is an error and never a pass. Without reserve, env create makes no limits call.

env create refuses to run when env.json already exists, so run env delete first. If the create fails after the signup was requested, env.json is still written so env delete can remove the org.

Writes .glassops/results/env-create.json with the facts env.file, env.id, env.record_id, env.name, env.auth_file and env.expires_at, plus the provider's own.

Exit When
0 The environment is active
1 The Dev Hub reserve is reached (the reserve check failed), so nothing was created
2 environments.<target> is not configured, env.json already exists, the hub login or guard failed, the limits could not be read, or the signup failed or timed out

glassops env delete

Deletes the environment from its hub. It reads env.json, or finds the environment by --name. With neither, nothing is recorded to delete: the delete check is skipped and the command exits 0. Deleting an environment that is already gone passes. After a delete from env.json, it removes the login file and env.json, so later steps fall back to the config. The default pr pipeline runs it with when: always.

Flag Default Meaning
--target ephemeral Environment name from the environments section
--name the one env create made Delete by name instead of from env.json
--env-file <dir>/.glassops/env/<target>/env.json env.json to read

Writes .glassops/results/env-delete.json. Exit 0 when the environment is deleted, already gone, or nothing is recorded. Exit 2 when the config, the hub login or env.json (for another target or hub) is wrong, or the delete fails.

glassops env sweep

Deletes every environment on the hub whose name starts with <prefix>- and that is older than --max-age, and lists what it deleted. It never matches the bare prefix. Run it on a schedule to remove environments that a cancelled run left behind.

Flag Default Meaning
--target ephemeral Environment name from the environments section, which supplies the hub and the prefix
--max-age environments.<target>.ttl_days as a duration Delete environments older than this, such as 24h. Must be above zero

Writes .glassops/results/env-sweep.json with the facts env.prefix, env.max_age, env.deleted and env.deleted_count. Exit 0 when the sweep finished, 2 when the config, the hub login or a delete failed.

glassops test

Logs in to the target, runs the guard, and runs the target's Apex tests with code coverage. It never deploys. It writes JUnit XML and checks the result against test.coverage.

Flag Default Meaning
--target Target name from glassops.yaml (required)
--level test.level for the target's tier, then test.level.default Test level, such as RunLocalTests
--tests Comma separated tests to run, for a level that names them
--wait the provider's How long to wait for the run, such as 30m
--resume Run Id of an earlier run to wait on again, instead of starting a new one
--junit <results-dir>/test.junit.xml JUnit XML file to write

Coverage. Percentages are rounded down, so a rounded-up value never passes a minimum. Both settings are optional:

  • test.coverage.org_min compares against the org-wide coverage that sf reports. That figure counts every class in the org, so it catches classes that no test touches.
  • test.coverage.class_min compares each class that the test run reports. test sees per-class coverage only for the classes in that report, so a class that no test ran against can be missing from it. Set org_min as well to catch those.

If a minimum is set and its figure is not reported, that is a failure, never a pass. A run that does not finish within --wait fails and names the run Id, and --resume waits on it again.

No tests found. When sf reports that no Apex tests were found, test records the fact test.none_found. It fails when org_min or class_min is set, because coverage cannot be checked. When neither is set, the status is empty, the tests check is skipped, and it exits 0.

Writes .glassops/results/test.json and the JUnit file (listed as an artifact). Facts: test.ran, test.failed, test.finished, test.run_id, test.org_coverage (a whole percent, absent when unknown), test.coverage.<Class>.percent and target.source.

Exit When
0 The tests passed and every set minimum is met, or no tests were found and no minimum is set
1 A test failed, the run did not finish, coverage is below a minimum or was not reported, or no tests ran while a minimum is set
2 The target could not be resolved, the login or guard failed, or the tests could not be run

glassops run

Runs the steps of one pipeline from glassops.yaml, in order, in one process. See Run a pipeline for the default pipelines.

glassops run pr
glassops run deploy --dry-run
Flag Default Meaning
--dry-run false Print the steps and the global flags each one gets. Runs nothing and removes nothing

A step is a glassops command line such as validate --target prod, or a map with step, when and, for an exec step, run (with optional target and login) or op.

When a step runs. when decides what happens after an earlier step failed.

when The step runs
success (the default) Only when no earlier step failed
failure Only when an earlier step failed
always Every time, including after a failure or a cancel

A step has failed when its exit code is not 0. After a plan step that exits 0, run reads .glassops/plan.json. An empty plan skips every later step that is not when: always, with the reason "the plan is empty". A plan that cannot be read is an error (exit 2), and later success steps are skipped, so it is never read as an empty plan. A cancel (Ctrl+C or SIGTERM) stops the current step and skips the rest except when: always steps, which still run with up to 2 minutes each. A cancelled run exits at least 2.

Exec steps. A step named exec runs its run command with sh -c in the project directory. The command inherits the environment and gets GLASSOPS_RESULTS_DIR, the absolute path of the results directory. Its output goes straight to the run's output. A zero exit passes and any other exit is a fail (exit 1). A command that cannot start, is stopped by a signal or is cancelled is an error (exit 2). Each exec step writes exec.<n>.json, where n counts exec steps from 1, with one command check and the facts exec.run, exec.index and exec.exit_code.

Exec steps with a target. An exec step with target runs its command logged in to that target, so a project script can use the Salesforce CLI against the org without its own login. In order, the step:

  1. On any tier but ephemeral, checks before any login that .glassops/permit.json allows this target, commit, plan and config, and binds the step's command. gate binds it with --exec-command followed by the step's run text exactly as written. It also checks that the working tree is the PERMIT's commit with no tracked file modified, so a script the command runs is the one the PERMIT was issued for. A pull request run has no PERMIT key, so it cannot run such a step against production. A tier ephemeral target needs only the guard.
  2. Logs in, runs the guard, and runs the command with the session's environment. For Salesforce that is HOME and USERPROFILE set to the session's private directory and SF_TARGET_ORG set to its login, so sf data query --query ... runs against the target. The token itself is never put in the environment, and GLASSOPS_PERMIT_KEY is removed from it. So are ACTIONS_ID_TOKEN_REQUEST_URL and ACTIONS_ID_TOKEN_REQUEST_TOKEN, because with Sigstore signing they let a job request the token that signs a PERMIT, so the command could otherwise sign its own.
  3. Masks login material in the command's output, such as a session Id or an auth URL, one line at a time.
  4. On Linux and macOS, runs the command in its own process group and kills the group when the command ends, so nothing it started keeps the login.
  5. Revokes the session's access token at the target, so a copy the command made stops working, then removes the session's directory. For Salesforce it uses the OAuth revoke endpoint. That ends the access token only, so the login the session came from works for the next step. A revoke that fails is a warning, not a failure, because the command has already run and the token still expires on its own.

An exec step can also set login to one of the named logins of its target, for a project that signs in to one org as more than one user. Step 2 then logs in with that login's auth instead of the target's own, and everything else is the same: the guard checks the target's own org Id, the PERMIT check and the output masking do not change, and the PERMIT binds the choice through the config hash.

The result exec.<n>.json also has the checks permit, tree, guard and revoke, and the facts exec.target, exec.tier, exec.session, exec.permit_id and exec.token_revoked. A step with login also has the fact exec.login, the login's name. It is absent for the default login, and never holds a user name, key, token or URL. A refusal is an error (exit 2) and runs nothing. A provider that cannot hand out a session, such as exec, refuses a step with a target.

Operation steps. An exec step with op: <name> runs an operation declared under operations in glassops.yaml. glassops op runs one the same way, outside a pipeline. The step takes target, run and login from the operation, so it cannot set them itself, and it runs through the same session path as an exec step with a target (login, guard, masking, process group, token revoke, session directory removed). Its permit check differs from a plain exec step:

  1. Before any login, it reads .glassops/permit.json and requires an operations PERMIT made by gate --ops that lists this operation and the SHA-256 of its run text, for this target, commit and config, and not expired. The PERMIT is checked with policy.operations.signing when that is set, else policy.permit.signing, and its lifetime may not exceed policy.operations.ttl. It reads no plan, so a pipeline made only of operations needs no plan step and runs with no plan file.
  2. It checks that the working tree is the PERMIT's commit with no tracked file modified, as a plain exec step does.
  3. An operation on a target of tier ephemeral is refused, because gate --ops issues no PERMIT for that tier.
  4. For a list run, it takes the param values from the PERMIT only, never from a flag or the environment. It rebuilds the argument list from the config and those values, checks that the PERMIT binds its digest, and checks that each file value at HEAD, and in the working tree, is the blob the PERMIT records. It then runs the program directly with that argument list and no shell, with the same session environment, masking, process group kill and revoke as any step with a target. A string run still runs with sh -c.
  5. When tools.sf.plugins lists plugins, each must be installed at its version, or the step refuses with a hint to run glassops setup. Any exec step with a target makes the same check.

A step is refused, as an error (exit 2) that runs nothing and logs in nowhere, when there is no PERMIT, the PERMIT is a deploy PERMIT, its signature, target, commit, config hash, operation name or command digest do not match, it has expired, or the tree check fails. An operation name that is not declared fails when the config loads. A plain exec step with run and target keeps its rules above and refuses an operations PERMIT by name. The result exec.<n>.json has the same checks and facts as an exec step with a target, plus the facts exec.op (the operation's name) and exec.permit_kind (operations). exec.run holds the operation's command for a string run. A list run has exec.argv (the argument list it ran) and exec.argv_sha256 (the digest the PERMIT binds) instead, and an operation with params has op.params, the values from the PERMIT. A file param adds a files check. With --dry-run the step prints as exec: operation <name> with the command or the argument list template, the target and the login.

Global flags. Every glassops step receives this run's --dir, --config, --results-dir and --ci, so all steps read one project and write to one results directory.

Stale results. Before the first step, a real run removes run.json and every top-level *.json file in the results directory whose schema is glassops.result/v1. It does not recurse and keeps every other file, such as SARIF and JUnit files. This stops an earlier run from reading as evidence for this one. The count is the fact run.stale_removed. A removal failure exits 2 before any step runs.

Exit code. The worst exit code of all steps. Any code other than 0 and 1 ranks as 2.

Writes .glassops/results/run.json with the facts run.pipeline, run.steps (index, step, when, argv, result, exit code, duration, skip reason), run.exit_code, run.empty_plan, run.cancelled and run.stale_removed, and one check per step. A pipeline that is not in the config, or a step that does not parse, exits 2 before anything runs.

With telemetry.otlp.endpoint set, run sends the finished run to an OpenTelemetry collector as trace spans after it writes the record. A failed export only warns. See OpenTelemetry export.

glassops op

Runs one operation that gate --ops has already allowed, the same way an operation step in a pipeline does, for a job that runs a single operation without a pipeline.

glassops gate --ops publish-site --param site=Portfolio
glassops op publish-site

It never gates. It refuses with exit 2, before reading anything else, when there is no PERMIT at <dir>/.glassops/permit.json. Then it makes every check an operation step makes, in the same order and before any login: the operations PERMIT, the tree, any file param blob and the configured plugins. The values of a list run come only from the PERMIT, so op has no --param flag. It runs the command with the session, masks the output, kills the process group and revokes the token.

It takes only the global flags --dir, --config, --results-dir and --ci. It writes .glassops/results/op.<name>.json with the same checks and facts as an operation step, including op.params.

Exit When
0 The command exited 0
1 The command exited with any other code
2 There is no PERMIT, a check refused, or the command could not start, was stopped or was cancelled

glassops setup

Installs each sf plugin under tools.sf.plugins at its exact version, with sf plugins install <name>@<version>. A plugin already at that version is left as it is, so a second run installs nothing. It also runs as a pipeline step, written setup.

setup never logs in and holds no session. The install runs without GLASSOPS_PERMIT_KEY, ACTIONS_ID_TOKEN_REQUEST_URL, ACTIONS_ID_TOKEN_REQUEST_TOKEN and any variable the config names as a $VAR, because a plugin install runs code from a package registry. sf asks before it installs a plugin that is not digitally signed. setup answers yes only for an entry with unsigned: true, so an unsigned plugin without it fails to install. After installing, it reads the installed versions back.

It needs provider salesforce. With no plugins listed it passes with a skipped plugins check. It writes .glassops/results/setup.json with one plugin.<name> check each and the fact setup.plugins (the versions sf lists).

Exit When
0 Every listed plugin is installed at its version
2 The config does not load, the provider cannot install plugins, or a plugin could not be installed at its version

glassops check

Runs your own project scripts, such as lint or unit test commands, and records the outcome. It does not replace those tools.

Scripts come from check.scripts in glassops.yaml, a list of name and run entries. Each runs with sh -c in the project directory, in order, and every script runs even after an earlier one failed. A script's output goes to the log and never into the result.

Flag Default Meaning
--script Run only the script with this name. An unknown name is an error

Writes .glassops/results/check.json with one check per script named script.<name> and the facts check.scripts, check.passed and check.failed. With no scripts configured the status is empty and the exit code is 0.

Exit When
0 Every script exited 0, or none are configured
1 A script exited non-zero
2 sh could not start, or --script names no entry

glassops analyze

Runs the Salesforce Code Analyzer over the project and records how many violations it found. It runs only when analyze.enabled: true is set in glassops.yaml. Without that, it records a skipped check, the status empty, and exits 0.

The analyzer needs Java 11 or newer and the Code Analyzer plugin of the Salesforce CLI. The standard glassops image has neither, so run analyze in the separate glassops-analyzer image, which adds them. glassops doctor checks for Java and the plugin when analyze.enabled is true. Only the Salesforce provider is supported.

Flag Default Meaning
--rule-selector analyze.rule_selector, else Recommended Rules to run
--sarif <results-dir>/analyze.sarif SARIF file to write

analyze does not decide what is too severe. It exits 0 whatever it found, so long as the analyzer ran. The gate rule analyzer_max_severity reads the counts and decides. It writes .glassops/results/analyze.json with the facts analyze.rule_selector, analyze.total and analyze.sev1 to analyze.sev5. The SARIF file and the analyzer's own JSON (.glassops/analyze/code-analyzer.json, beside the results directory) are listed as artifacts, and report merges the SARIF file into its output.

Exit When
0 The analyzer ran, or analyze is off
2 The analyzer could not run, its output could not be read, or the provider is not Salesforce

The smart seed

A destructive change, such as a deleted field, cannot be validated on a fresh scratch org, because the component it deletes was never there. When validate runs against a scratch org and the change set has destructive members, it first deploys the base state they need. The base ref is the plan's from ref. salesforce.ephemeral.seed chooses how:

Mode What it deploys
minimal (the default) Only the destructive members, from the base ref, plus the parent object of any child component (field, record type, validation rule and similar) whose parent is a custom object (__c, __mdt or __e)
full The whole source at the base ref
off Nothing. The destructive change is validated against the org as it is

If a minimal seed fails because something else is missing (an error such as Entity 'Widget__c' not found), the seed falls back to the full seed, records validate.seed.fallback: true and raises a CI warning. A failed seed stops validate before it runs. The seed applies to scratch targets only. validate records validate.seed.mode, validate.seed.fallback and validate.seed.members.


Authentication

Each target names its login under auth. There are three methods, and every secret value is a $VAR that names an environment variable. Values stay in your CI's secret store and never go in the file.

Method Fields Notes
jwt username, client_id, key, optional instance_url key is a $VAR that holds the private key as PEM text. A value that is not PEM text is read as the path of a key file
sfdx-url url url is a $VAR that holds a force:// auth URL
access-token token, instance_url token is a $VAR that holds an access token
targets:
  devhub:
    id: $SF_DEVHUB_ORG_ID
    tier: devhub
    auth: { method: jwt, username: $SF_USERNAME, client_id: $SF_CLIENT_ID, key: $SF_JWT_KEY }
  ephemeral:
    id: $SF_EPHEMERAL_ORG_ID
    tier: ephemeral
    auth: { method: sfdx-url, url: $SF_EPHEMERAL_AUTH_URL }

Isolated Salesforce CLI state

Every command that talks to an org runs the Salesforce CLI with its own temporary home directory (HOME and USERPROFILE). It never reads or writes the Salesforce CLI logins you have on your machine. The temporary directory, and any key file written into it, is removed when the command ends, including when it is stopped with Ctrl+C or SIGTERM. Logins are retried only on network and server errors, never on a bad key, an unknown user or an expired token.

The guard

Before any step does anything to a target, the guard compares the org the login reached with the target in the config. A mismatch exits 2.

  • The Id is compared on its first 15 characters, case-sensitively, so a 15 and an 18 character form of one Id match.
  • A target with no Id configured fails, because it cannot be checked.
  • Tier prod and tier devhub need a production org.
  • Tier ephemeral needs a scratch org.
  • Every other tier checks the Id only.

What is never logged

Results, step outputs, CI annotations and error messages never contain the org's company name, tokens, private keys, auth URLs or full usernames. Usernames are masked to their first character and domain, such as u***@example.com. Email-shaped text in a tool's error message is masked the same way.

Validate is check-only

validate is check-only by construction. It only ever runs sf project deploy validate, never a deploy, and --check-only=false is refused. After the run it reads the full result with sf project deploy report and exits 2 if the target reports anything other than a check-only run. Keep a Dev Hub for managing scratch orgs, and validate against a scratch org or a sandbox.


Global flags

Flag Default Meaning
--dir . Project root
--config <dir>/glassops.yaml Config file
--results-dir <dir>/.glassops/results Where results are written
--ci auto CI system: auto, github, bitbucket, gitlab or local. See Bitbucket and GitLab

Exit codes

Code Meaning
0 Pass
1 A policy or check failed. The tool itself worked
2 A tool or infrastructure error stopped the command, or the command line was invalid

A tool error is printed to stderr as glassops: <message> on one line. A line break inside the message is replaced, so output that a CI runner scans for commands cannot start a new line.


Results

Every command writes .glassops/results/<step>.json in one envelope, described by schemas/result.json:

{
  "schema": "glassops.result/v1",
  "step": "doctor",
  "status": "pass",
  "started": "2026-10-26T12:00:00Z",
  "ended": "2026-10-26T12:00:02Z",
  "provider": "salesforce",
  "checks": [{ "name": "tool.sf", "status": "pass", "detail": "2.155.7" }],
  "facts": { "tools.sf": "2.155.7" },
  "artifacts": [],
  "errors": []
}

status is one of pass, fail, error, skipped or empty.

On GitHub, each command also sets the step outputs status and result (the result file path), adds an error annotation for each failed check, and writes a table to the job summary.


Configuration

glassops.yaml is optional. Every key, with an example, is in the configuration reference. The schema is schemas/config.json.


End-to-end check

The workflow cli-e2e.yml creates a scratch org in a Dev Hub, runs doctor --auth, plan and validate against it, and deletes the org. It runs on demand and on pushes to main, and it skips with a notice when the Salesforce secrets are not set. The scripts are in scripts/e2e.


Install

The current release is v1.0.0 on the releases page. Releases, images and licenses says which release first has each command and feature.

Route What you get What you need
Published image ghcr.io/glassops-platform/glassops:v1, or 1.0.0 for a fixed release The release binary with Node 22, the Salesforce CLI and sfdx-git-delta Docker
go build -o glassops ./cmd/glassops The current binary Go 1.27.4 or later, and the host tools below
docker build -t glassops . The current binary in an image with the tools, plus cosign and opa Docker. Add docker build -f Dockerfile.analyzer -t glassops-analyzer . for analyze

A built Linux binary also runs inside the published image. Mount it over the image's own:

docker run --rm -v "$PWD:/work" -w /work -v "$PWD/glassops:/usr/local/bin/glassops"   ghcr.io/glassops-platform/glassops:1.0.0 doctor

Host prerequisites for go build. git always. For a Salesforce project also the Salesforce CLI sf and its sfdx-git-delta plugin:

sf plugins install sfdx-git-delta

Provider exec needs only git and sh. ./glassops doctor checks the tools and says which one is missing. Release tags, image tags, the license scan and the third party notices are described in Releases, images and licenses.