The Trunk CLI has its top-level config defined inDocumentation Index
Fetch the complete documentation index at: https://trunk-4cab4936-sam-gutentag-flaky-tests-new-monitors.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
.trunk/trunk.yaml.
trunk init and is the central source of truth for how Trunk operates inside your repository. As we build new services and features, we’ll extend trunk.yaml to include configuration sections for them. We believe strongly in “configuration as code” and being able to guarantee that trunk can be run reproducibly.
Config format
The Trunk configuration file is written in YAML and is meant to be self-descriptive. Below is a sample config file to help you understand how the pieces come together. Alternatively, you can also refer to thetrunk.yaml in our GitHub Action as an example or trunk-yaml-schema.json.
version
The version field is the schema version of trunk.yaml.
cli
version, cli allows you to specify default command line arguments using the options field. Specified args will be appended to strictly matched commands during trunk invocations. Specifying ALL as a commands element applies its options to all trunk subcommands. Any command line options will take precedence over these args.
Some examples using the configuration above:
trunk checkresolves totrunk check -y --monitor=truetrunk check -nresolves totrunk check -n --monitor=truetrunk fmtresolves totrunk fmt -y --monitor=true
repo
origin remote, but if you don’t want your origin to be used for this purpose, you can explicitly specify your canonical repository.
Other features - namely trunk check - need to be aware of the primary upstream branch that everyone branches from. If you use main or master, trunk can infer this; however, if you use some other primary branch, then you may want to consider setting this.
The above configuration is how you would specify that https://github.com/github/gitignore is your canonical repository and that main is the branch which trunk should always think of as your upstream branch.
api
trunk.yaml file.
trunk_remote_hint
<remote_host>/<organization>/<repo_name> instead of defaulting to origin. It will then use this remote as the default upstream for computing changed files.
Stacked PR support
trunk will auto-detect all changed files relative to your main branch. If you would instead like it to compare against the upstream of your current git branch, you can enable this feature by setting use_branch_upstream to true.
Disable upgrade notifications
Trunk will periodically tell you to upgrade to a newer version if one is available. If you prefer not to see these notifications, edit (or add) the section of your.trunk/trunk.yaml to include the following lines:
Overriding defaults
Trunk ships with a default configuration whichtrunk.yaml is merged into to produce the actual configuration that Trunk runs with. You can view this merged configuration using trunk print-config.
You may find while using Trunk that you want to modify one of these defaults: perhaps you want clang-tidy to not run on the upstream, or maybe you want the node runtime to include another environment variable. In these cases, you can specify the field in your trunk.yaml to override the default value.
Let’s take clang-tidy as an example, which ships with the following default configuration:
disable_upstream to false, you could, in your own trunk.yaml, specify:
[name, version, platforms]. For example, if you wanted to disable batching when running ktlint on Windows, you could consider its default configuration:
node runtime:
${home}/my/special/node/path to PATH, you could specify the following:
Validation
Custom linter, download, and runtime configs must be defined in full and will be validated. Overrides of existing linter, download, and runtime configs can be partial overrides. They do not have to be full definitions. Merged configurations are subject to the same validation that custom linters are - they must all have a name, type, command, and eithersuccess_codes or error_codes set.
Known limitations
- Scalar values are overridden in a straightforward manner - the value specified in the override
takes the place of the default, and otherwise, default values are retained. - To override a sequence value in the default (ex.
environmentin thenoderuntime), it is
necessary to fully specify the new sequence. This is why theenvironmentoverride above also definesHOME. If you just wanted to add a new value, you would have to copy in the existing
sequence to your overriding config, and add your new value to the end of the list. - It is not possible to set sequences of non-zero length to zero length. For example, if the
default config hassuccess_codes: [0], you may override this tosuccess_codes: [0, 1], but you cannot clear its value.