Try Serpent Free
← Salesforce DevOps Glossary

2GP (Second-Generation Packaging)

Salesforce's modern packaging model that builds packages from code in version control instead of clicking through an org.

Definition

2GP (second-generation packaging) is Salesforce's source-driven packaging model: metadata lives in version control and package versions are built from that source using Salesforce CLI and a Dev Hub, rather than being defined by clicking through a packaging org (1GP). It produces both managed and unlocked package types from the same underlying model.

Every build runs in an isolated scratch org, enforces dependency declarations between packages, and produces an immutable version with tracked ancestry back to its predecessor, giving real semantic versioning that 1GP never had.

It's the model Salesforce recommends for all new managed package development and most ISV work, since it enables CI/CD and automated per-version testing. The tradeoff is setup complexity: teams need a Dev Hub, scratch org access, and a CI pipeline before 2GP pays off.

In practice

How it works in Serpent

Serpent runs 2GP pipelines natively on every plan, including scratch org provisioning, dependency-aware version bumps, and promotion between package versions, without requiring a separate CI system or hand-written CLI scripts. Builds trigger automatically as tasks complete, version ancestry is tracked so upgrades stay clean, and subscriber org tracking shows exactly which package version each customer runs. Since 2GP setup is usually the biggest barrier to adoption, Serpent's goal is to make the source-driven model usable by teams without a dedicated release engineer. See 2GP CI/CD in Serpent for the full pipeline.

Commit-to-package mapping in Serpent
Common questions

2GP (Second-Generation Packaging), answered

Do I need a separate CI tool for 2GP with Serpent?
No. Serpent runs build, version, and promotion steps for 2GP packages natively, so there's no separate CI system to configure or maintain.
Do I need scratch orgs to build 2GP packages?
Yes. Every 2GP package version builds in an isolated scratch org before it's created, which is why a connected Dev Hub with scratch org capacity is required.
Can a 2GP package be both managed and unlocked at the same time?
No. Package type is set when you create the package and can't be changed afterward, so managed and unlocked 2GP packages are built and versioned separately.

Start free. No credit card, no install, no commitment.

Set up in under 15 minutes. No DevOps hire needed.

Curious about faster shipping before you dive in? Let's talk

Commitment free!