Baselines#
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:
- A collection of rules — Baselines allow you to define a set of rules that will run each time the baseline is specified.
- Paired with configuration — Baselines allow you to pair configuration so rules run consistently.
Using baselines#
To use a baseline, specify it by name when you run PSRule. For example:
- name: Run PSRule
uses: microsoft/ps-rule@v2.9.0
with:
modules: 'PSRule.Rules.Azure'
baseline: 'Azure.GA_2024_09'
- task: ps-rule-assert@2
displayName: Run PSRule
inputs:
modules: 'PSRule.Rules.Azure'
baseline: 'Azure.GA_2024_09'
Assert-PSRule -InputPath '.' -Baseline 'Azure.GA_2024_09' -Module PSRule.Rules.Azure;
Baseline groups#
v2.9.0
In addition to specifying a baseline by name you can use a baseline group. A baseline group provides an alternative name to an existing baseline. Baseline groups allowing you to decouple pipeline configuration from the baseline name when it changes often.
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_2024_09
preview: PSRule.Rules.Azure\Azure.Preview_2024_09
- The
latest
baseline group is set toAzure.GA_2024_09
within thePSRule.Rules.Azure
module. - The
preview
baseline group is set toAzure.Preview_2024_09
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;
Defining baselines#
A baseline is defined as a resource within YAML or JSON. Custom baselines can be defined side-by-side with rules you create or included separately.
Continue reading baseline reference.