Environments

This feature requires sfp-pro with sfp-server

Environments are the central concept in a Flxbl project. An environment links a repository branch to a registered Salesforce org, providing controlled access to credentials for team members and CI/CD pipelines.

Orgs vs Environments

Understanding the distinction between Orgs and Environments is essential:

Concept
Description
Scope

Org

A registered Salesforce org (production, sandbox, scratch org) with stored credentials

Global - shared across all repositories

Environment

A deployment target that links a repository + branch to a registered org

Repository-specific

┌─────────────────────────────────────────────────────────────────────────────┐
│                         Orgs vs Environments                                 │
├─────────────────────────────────────────────────────────────────────────────┤
│                                                                              │
│   REGISTERED ORGS (Global)           ENVIRONMENTS (Per Repository)          │
│   ────────────────────────           ─────────────────────────────          │
│                                                                              │
[email protected]    ─────────► Production (myorg/app-1, main)         │
│                           └────────► Production (myorg/app-2, main)         │
│                                                                              │
[email protected] ─────────► UAT (myorg/app-1, release/*)           │
│                           └────────► QA (myorg/app-2, develop)              │
│                                                                              │
[email protected]        ─────────► (DevHub for scratch org pools)         │
│                                                                              │
└─────────────────────────────────────────────────────────────────────────────┘

Key differences:

Org Commands (sfp server org)

Environment Commands (sfp server environment)

Register Salesforce credentials

Link orgs to repository branches

Store/update auth details

Control access via locking

JIT sandbox registration

Provide deployment targets

Direct org access via org login

Credential access requires lock or --auth-type

What is an Environment?

An environment represents a deployment target - the combination of:

  • Repository: Which codebase (e.g., myorg/salesforce-app)

  • Branch: Which code branch (e.g., main, develop)

  • Salesforce Org: Which org to install artifacts

  • Category: The environment type (dev, test, release)

Environment Categories

Category
Purpose
Typical Use

dev

Development

Feature development, local testing

test

Testing

UAT, SIT, QA environments

snapshot

Snapshots

Point-in-time environment copies

release

Production

Production and staging releases

Complete Setup: From Org to Environment

Before creating environments, you need to register your Salesforce orgs with sfp-server. Here's the complete flow:

Step 1: Register Orgs

First, register your Salesforce orgs with sfp-server. See Org Registration for complete details.

Step 2: Create Environments

Link registered orgs to repository branches.

Creating Environments

Basic Creation

With Metadata and Tags

Listing Environments

List All

Output:

Filter by Category

Retrieving Environments

Basic Retrieval (No Credentials)

Get environment information without credentials:

Credential Access Methods

There are two ways to get credentials for an environment:

Method 1: Lock-Based Access (For Deployments)

Method 2: Direct Access with --auth-type (No Locking)

This retrieves a short-lived access token (~2 hours) and authenticates locally.

When to Use Which Method

Scenario
Method
Why

CI/CD deployments

Lock-based

Prevents concurrent deployments

Running tests

--auth-type

No locking overhead needed

Quick data queries

--auth-type

Read-only, no conflict risk

Long-running operations

Lock with --wait

Ensures exclusive access

Parallel pipeline jobs

Lock-based

Queue management

Auth Type Selection

Auth Type
Lifetime
Use Case

accessToken

~2 hours

Short operations, better security

sfdxAuthUrl

Until revoked

Scratch org pools, extended sessions

Environment Properties

Core Properties

Property
Description

name

Unique name within repository

category

dev, test, snapshot, release

branch

Git branch pattern

description

Human-readable description

salesforceUsername

Linked Salesforce org

isActive

Whether environment is active

isDefault

Default for its category

Extended Properties

Property
Description

tags

Searchable tags

metadata

Custom JSON metadata

orchestrationOrder

Deployment sequence

devHubUsername

Parent org (for sandboxes)

Lock Status

When an environment is locked:

Updating Environments

Deleting Environments

Credential Access Control

Role-Based Access

Role
Can View
Can Get Credentials
Can Modify

Member

Yes

No

No

Owner

Yes

Yes

Yes

Application

Yes

Yes

Limited

Audit Trail

All credential access is logged:

CI/CD Integration

GitHub Actions

Matrix Deployment

Environment Patterns

Standard Pipeline

Multi-Region

Feature Environments

Last updated