Baselines#
Abstract
A baseline is a set of rules and configuration options. You can define a named baseline to run a set of rules for a specific use case.
Baselines cover two (2) main scenarios:
- Rules — PSRule supports running rules by name or tag. However, when working with a large number of rules it is often easier to group and run rules based on a name.
- Configuration — A baseline allows you to run any included rules with a predefined configuration by name.
Defining baselines#
A baseline is defined as a resource within YAML or JSON. Baselines can be defined side-by-side with rules you create or included separately as a custom baseline.
Continue reading baseline reference.
Baseline groups#
v2.9.0
In addition to regular baselines, you can use a baseline group to provide a friendly name to an existing baseline. A baseline groups are set by configuring the Baseline.Group option.
Experimental
Baseline groups are a work in progress and subject to change. Currently, baseline groups allow only a single baseline to be referenced. Join or start a discussion to let us know how we can improve this feature going forward.
Tip
You can use baseline groups to reference a baseline. If a new baseline is made available in the future, update your baseline group in one place to start using the new baseline.
In the following example, two baseline groups latest
and preview
are defined:
baseline:
group:
latest: PSRule.Rules.Azure\Azure.GA_2023_03
preview: PSRule.Rules.Azure\Azure.Preview_2023_03
- The
latest
baseline group is set toAzure.GA_2023_03
within thePSRule.Rules.Azure
module. - The
preview
baseline group is set toAzure.Preview_2023_03
within thePSRule.Rules.Azure
module.
To use the baseline group, prefix the group name with @
when running PSRule.
For example:
- name: Run PSRule
uses: microsoft/ps-rule@v2.9.0
with:
modules: 'PSRule.Rules.Azure'
baseline: '@latest'
- task: ps-rule-assert@2
displayName: Run PSRule
inputs:
modules: 'PSRule.Rules.Azure'
baseline: '@latest'
Assert-PSRule -InputPath '.' -Baseline '@latest' -Module PSRule.Rules.Azure -Format File;