moon ci command is a special command that should be ran in a continuous integration (CI) environment, as it does all the heavy lifting necessary for effectively running tasks in CI.
By default this will run all tasks that are affected by changed files and have the runInCI task option enabled.
runInCI.
How it works
Themoon ci command is optimized for CI environments and automatically:
- Enables CI mode - Automatically detects CI environment and adjusts behavior
- Always checks affected - Compares against base branch to find changed files
- Filters by runInCI - Only runs tasks explicitly marked for CI
- Syncs workspace - Ensures workspace is synced before running tasks
- Includes dependents - Runs direct dependents for regression checking
- Continues on failure - Continues running tasks even when some fail
- Shows detailed summary - Provides comprehensive output for debugging
Arguments
...[target]- Task targets to run. If not provided, runs all tasks matching criteria.
Options
Inherits most options frommoon exec and pre-fills with:
--affected- Always enabled--ci- Always enabled--on-failure=continue- Continues execution on failure--summary=detailed- Shows detailed summary--upstream=deep- Includes all dependencies--downstream=direct- Includes direct dependents
Common options
-f,--force- Force run and bypass cache, ignore changed files.-i,--interactive- Run the pipeline and tasks interactively.
Affected options
--base <BASE>- Base branch, commit, or revision to compare against. Auto-detected from CI environment.--head <HEAD>- Current branch, commit, or revision to compare with. Auto-detected from CI environment.-g,--include-relations- Include graph relations for affected checks.--status <STATUS>- Filter changed files based on a changed status.--stdin- Accept changed files from stdin for affected checks.
Graph options
--downstream <DEPTH>- Control the depth of downstream dependents. Default isdirectin CI.--upstream <DEPTH>- Control the depth of upstream dependencies. Default isdeep.
Parallelism options
--job <INDEX>- Index of the current job (0 based).--job-total <TOTAL>- Total amount of jobs to run.
Examples
Basic CI run
Run all CI-enabled tasks affected by changes:Run specific targets in CI
CI with custom base branch
Split CI jobs
Distribute work across multiple CI jobs:Force run without cache
CI with status filter
Only check specific types of changed files:CI environment detection
The command automatically detects when running in CI and extracts information from environment variables:| CI Provider | Base Branch | Head Revision |
|---|---|---|
| GitHub Actions | GITHUB_BASE_REF | GITHUB_SHA |
| GitLab CI | CI_MERGE_REQUEST_TARGET_BRANCH_NAME | CI_COMMIT_SHA |
| CircleCI | CIRCLE_BRANCH | CIRCLE_SHA1 |
| Travis CI | TRAVIS_BRANCH | TRAVIS_COMMIT |
| Jenkins | CHANGE_TARGET | GIT_COMMIT |
| Bitbucket | BITBUCKET_PR_DESTINATION_BRANCH | BITBUCKET_COMMIT |
Task configuration
Tasks must be explicitly marked to run in CI using therunInCI option:
Comparison with moon run
| Feature | moon ci | moon run |
|---|---|---|
| Affected | Always enabled | Optional |
| CI mode | Always enabled | Optional |
| Task filter | Only runInCI tasks | All tasks |
| On failure | Continue | Bail (stop) |
| Summary | Detailed | None |
| Dependents | Direct | None |
| Workspace sync | Always | Only in CI |
Best practices
Configure runInCI appropriately
Only mark tasks that should run in CI:Use with pull request workflows
Handle all changed files
Ensure you fetch enough git history:Monitor task failures
Sincemoon ci continues on failure, check exit code:
Environment variables
The following environment variables can be used:MOON_FORCE- Same as--forceMOON_BASE- Same as--baseMOON_HEAD- Same as--headMOON_INCLUDE_RELATIONS- Same as--include-relationsMOON_JOB- Same as--jobMOON_JOB_TOTAL- Same as--job-total
Configuration
tasksin.moon/tasks/*tasksinmoon.*tasks.*.options.runInCIinmoon.*