Skip to content

Commit 8c4c436

Browse files
authored
DEVOPS-764 feat: add support for skipping org pool checkout via env var (#12)
* DEVOPS-764 feat: add support for skipping org pool checkout via environment variable * DEVOPS-764 docs: clarify truthy and falsy values for Clariti checkout in scratch orgs
1 parent 2513952 commit 8c4c436

3 files changed

Lines changed: 66 additions & 1 deletion

File tree

cumulusci/core/config/scratch_org_config.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,15 @@ def days_alive(self) -> Optional[int]:
9999
def create_org(self) -> None:
100100
"""Uses sf org create scratch to create the org"""
101101
try:
102-
if self._try_checkout_pooled_org():
102+
if (
103+
self.config.get("org_pool_id")
104+
and self._should_skip_pool_checkout_env()
105+
):
106+
self.logger.info(
107+
"Skipping Clariti org pool checkout because CCI_DISABLE_POOL_CHECKOUT "
108+
"is set."
109+
)
110+
elif self._try_checkout_pooled_org():
103111
return
104112
if (
105113
self.config.get("org_pool_id")
@@ -123,6 +131,10 @@ def create_org(self) -> None:
123131
finally:
124132
self._cleanup_tmp_config()
125133

134+
def _should_skip_pool_checkout_env(self) -> bool:
135+
value = os.getenv("CCI_DISABLE_POOL_CHECKOUT", "")
136+
return value.lower() in ("1", "true", "yes", "on")
137+
126138
def _create_org_via_sfdx(self) -> None:
127139
if not self.config_file:
128140
raise ScratchOrgException(

cumulusci/core/config/tests/test_config_expensive.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,43 @@ def test_create_org_falls_back_when_checkout_fails(self, mock_checkout):
929929

930930
config._create_org_via_sfdx.assert_called_once()
931931

932+
@mock.patch.dict(os.environ, {"CCI_DISABLE_POOL_CHECKOUT": "1"})
933+
@mock.patch("cumulusci.core.config.scratch_org_config.checkout_org_from_pool")
934+
def test_create_org_skips_pool_checkout_when_disabled(self, mock_checkout):
935+
mock_keychain = mock.Mock()
936+
mock_keychain.project_config = mock.Mock(project__name="Project")
937+
config = ScratchOrgConfig(
938+
{
939+
"config_file": "tmp.json",
940+
"org_pool_id": "Pool42",
941+
},
942+
"dev",
943+
mock_keychain,
944+
)
945+
config._create_org_via_sfdx = mock.Mock()
946+
947+
config.create_org()
948+
949+
config._create_org_via_sfdx.assert_called_once()
950+
mock_checkout.assert_not_called()
951+
952+
@mock.patch("cumulusci.core.config.scratch_org_config.checkout_org_from_pool")
953+
def test_create_org_without_pool_id_creates_from_scratch(self, mock_checkout):
954+
mock_keychain = mock.Mock()
955+
config = ScratchOrgConfig(
956+
{
957+
"config_file": "tmp.json",
958+
},
959+
"dev",
960+
mock_keychain,
961+
)
962+
config._create_org_via_sfdx = mock.Mock()
963+
964+
config.create_org()
965+
966+
config._create_org_via_sfdx.assert_called_once()
967+
mock_checkout.assert_not_called()
968+
932969
@mock.patch("cumulusci.core.config.scratch_org_config.import_sfdx_org_to_keychain")
933970
@mock.patch("cumulusci.core.config.scratch_org_config.checkout_org_from_pool")
934971
@mock.patch("cumulusci.core.config.scratch_org_config.set_sf_alias")

docs/scratch-orgs.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,22 @@ fresh scratch org if the checkout fails or the pooled org is already expired. Se
299299
`CCI_DISABLE_SCRATCH_FALLBACK=1` while you debug checkout issues to prevent new
300300
scratch orgs from being created.
301301

302+
If the pool identifier should remain configured but you want to avoid the
303+
checkout (for example, because you are creating an org that will later be
304+
imported into the pool), set `CCI_DISABLE_POOL_CHECKOUT=1` in your environment.
305+
CumulusCI leaves the pool metadata intact while creating the org from scratch.
306+
307+
### Checkout behavior matrix
308+
309+
| `org_pool_id` | `CCI_DISABLE_POOL_CHECKOUT` | `CCI_DISABLE_SCRATCH_FALLBACK` | Result |
310+
|--------------:|----------------------------|-------------------------------|--------|
311+
| not set | any | any | Always creates a scratch org via `sf org create scratch`. |
312+
| set | truthy | any | Skips Clariti checkout and creates a scratch org. |
313+
| set | falsy | truthy | Attempts Clariti checkout; failing checkout raises `ScratchOrgException`. |
314+
| set | falsy | falsy | Attempts Clariti checkout; failing checkout falls back to scratch org creation. |
315+
316+
**Note:** "truthy" values include `1`, `true`, `yes`, or `on` (case-insensitive); "falsy" includes empty string, `0`, `false`, `no`, or `off`.
317+
302318
## Use a Non-Default Dev Hub
303319

304320
By default, CumulusCI creates scratch orgs using the DevHub org

0 commit comments

Comments
 (0)