GitLab CI
The following example shows how to use Momentic with GitLab CI.
For more usage examples, see the momentic-ai/examples repository.
For a given root package.json
:
Create a file called gitlab-ci.yml
in your repository with the following contents:
Authentication
To run any commands, you must authenticate with Momentic. You can do this by adding the MOMENTIC_API_KEY
environment variable to your GitLab CI workflow.
- Create an API key in Momentic Cloud.

Copy the value to a safe place. You’ll need it in a moment.
- Go to your GitLab repository settings and click on the Settings and then CI/CD tab. Create a new variable called
MOMENTIC_API_KEY
and enter the value of your API key.


- GitLab CI automatically loads environment variables stored in project settings into the CI environment. No modifications are necessary for the CI file.
Sharding
If you have a large test suite, you can use sharding to run tests in parallel. This can significantly speed up your CI runs.
To shard the test suite, pass the --shard-index
and --shard-count
options to the momentic run
command. The shard-index
is the index of the current shard (starting from 1), and shard-count
is the total number of shards.
In order to collect test results inside a single run group in Momentic cloud, you need to add a separate step after all tests complete to merge and upload results.