npx momentic run. Set
MOMENTIC_API_KEY in your provider’s secret store. Sharding examples are
included for CircleCI, Buildkite, and Azure DevOps. For GitHub Actions and
GitLab CI, see GitHub Actions and
GitLab CI. More configs live in
momentic-ai/examples.
Every example assumes momentic is a dev dependency in the root package.json:
package.json
CircleCI
For CircleCI, create.circleci/config.yml in your
repository:
config.yml
CircleCI authentication
Set theMOMENTIC_API_KEY environment variable in your CircleCI project
settings.
- Create an API key in the Momentic dashboard.
-
Go to your CircleCI project settings and click the Environment Variables
tab. Create a new secret called
MOMENTIC_API_KEYand enter your API key. - CircleCI automatically loads environment variables stored in project settings into the CI environment. The CI file needs no changes.
CircleCI sharding
To shard your tests, 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.
To collect test results inside a single run group in the Momentic dashboard, add
a separate step after all tests complete to merge and upload results.
config.yml
Jenkins
Configure a NodeJS tool namedNodeJS 22 in Jenkins
with Node.js 22.12.0 or later in the 22.x line. Node.js 23 is unsupported.
Commit package-lock.json for npm ci, then create this Jenkinsfile:
Jenkinsfile
Jenkins authentication
Add themomentic-api-key credential to your Jenkins instance.
- Create an API key in the Momentic dashboard.
- In Manage Jenkins > Credentials, add a new global credential.
-
At the top of your
Jenkinsfile, provide the following environment variables to the pipeline:
Jenkinsfile
Travis CI
For Travis CI, create.travis.yml in your
repository:
.travis.yml
Travis CI authentication
Set theMOMENTIC_API_KEY environment variable in your Travis repository
settings.
- Create an API key in the Momentic dashboard.
-
Go to your Travis repository settings and scroll down to the Environment
Variables section. Create a new variable called
MOMENTIC_API_KEYand enter the value of your API key. - Travis CI automatically loads environment variables stored in project settings into the CI environment. The CI file needs no changes.
Buildkite
Run Momentic on Buildkite. Buildkite is auto-detected, so Momentic reads git metadata (branch, commit, pipeline) from the agent. Create a file called.buildkite/pipeline.yml in your repository with the
following contents:
.buildkite/pipeline.yml
Buildkite authentication
To run tests, you must authenticate with Momentic by providing theMOMENTIC_API_KEY environment variable.
- Create an API key in the Momentic dashboard.
- Store it with the
Buildkite secrets
tooling your agents use: the
secretsBuildkite plugin, your secrets manager, or an agent environment hook. Do not commit it to the pipeline file. - Expose it to the
momenticsteps asMOMENTIC_API_KEY:
.buildkite/pipeline.yml
Buildkite sharding
Buildkite exposes the parallel job index asBUILDKITE_PARALLEL_JOB (0-indexed)
and the total as BUILDKITE_PARALLEL_JOB_COUNT. Momentic’s --shard-index is
1-indexed, so add one. To collect every shard into a single run group in the
dashboard, add a step that merges and uploads results after the tests finish.
.buildkite/pipeline.yml
Buildkite Test Analytics
Momentic can emit a Buildkite-format JSON report with thebuildkite-json
reporter for
Buildkite Test Analytics:
Azure DevOps
Run Momentic on Azure Pipelines. Momentic detects Azure DevOps whenSystem.CollectionUri contains azure and
reads git metadata from dotted environment variables such as
Build.SourceVersion.
Create a file called azure-pipelines.yml in your repository with the following
contents:
azure-pipelines.yml
Azure DevOps authentication
To run tests, you must authenticate with Momentic by providing theMOMENTIC_API_KEY environment variable.
- Create an API key in the Momentic dashboard.
- Add it as a
secret pipeline variable
named
MOMENTIC_API_KEY. Mark it as secret so logs mask it. Do not commit it to the pipeline file. - Azure does not pass secret variables to scripts on its own. Map the variable
into the environment of each
momenticstep withenv:, as shown above.
Azure DevOps sharding
Use a parallel job strategy and use the 1-indexedSystem.JobPositionInPhase and total
System.TotalJobsInPhase for --shard-index / --shard-count. To collect
every shard into a single run group in the dashboard, add a job that merges and
uploads results after the tests finish.
azure-pipelines.yml