With snapshots, you can pin a specific version of tests and flows to a mabl environment. This article explains how to manage snapshots:
- Create and update snapshots
- Review snapshotted tests and flows
- Remove a snapshot
- Check an environment’s snapshot status
What are snapshots?
For more details on snapshots, including what they are, how they work, and why you might use them, check out this article.
Create and update snapshots
You can create and update snapshots with the mabl deployments create
command in the mabl CLI. At a minimum, the command must include these two options:
-
-e
or--environment-id
: ID of the environment you want to create the snapshot for -
--snapshot-from
: name of the branch you want to use, such as “master” or “test_branch_2”
mabl deployments create -e [env-id] --snapshot-from [branch_name]
Running this command creates a deployment event in mabl, which triggers a run for all active plans in this environment.
To create or update a snapshot for an environment but not trigger a run for the test plans associated with it, add a nonexistent label using the -l
or --labels
option. The following example assumes that there is not a plan label called “fake” in your workspace!
mabl deployments create -e [env-id] --snapshot-from master -l fake
Review snapshotted tests and flows
To review all the tests and flows that were snapshotted, go to Tests > Branches. Snapshots appear within the list of branches and are indicated with status “snapshot”. Snapshot names are automatically generated based on the environment ID they are created for.
List of mabl test branches and snapshots
You can also identify which version of a test has been snapshotted by going to the test details and looking under the change history tab.
Test change history with a version pinned to a snapshot environment
Remove a snapshot
To remove a snapshot, you must disassociate the snapshot from the environment and remove the snapshot from the mabl UI.
Disassociate the snapshot from the environment
Create a deployment event in the mabl CLI for the environment without the --snapshot-from
option. Provide the ID for the environment that you want to remove the snapshot from:
mabl deployments create -e [env-id]
Remember that deployment events trigger a run for all active tests that match the parameters that you provide. To avoid running any tests, include the -l
or --label
option with a nonexistent label:
mabl deployments create -e [env-id] -l nonexistent-label
Going forward mabl resorts to using the master branch version of the tests for your plan runs unless you specify a different branch.
Remove the snapshot from the mabl UI
Go to Tests > Branches in the mabl app and delete the snapshot from the mabl UI so it no longer appears in the list.
Re-associate a snapshot with an environment
If you disassociated a snapshot from an environment by mistake, you can run this command to pin the environment to the snapshot again:
mabl environments update [env-id] --mabl-branch [snapshot-name]
Check an environment’s snapshot status
To check whether an environment is configured to use a snapshot, run the following command in the mabl CLI:
mabl environments describe [env-id]
The mabl CLI returns metadata on the environment, including whether or not it is configured to use a snapshot:
- If the metadata shows
use_source_control_tag: true
, the environment is configured to use a snapshot. - If the metadata shows
use_source_control_tag: false
, or theuse_source_control_tag
property is absent, the environment is not configured to use a snapshot.