Skip to content

Commit

Permalink
Added outcome filtering #570 (#571)
Browse files Browse the repository at this point in the history
  • Loading branch information
BernieWhite authored Oct 17, 2022
1 parent 4743c95 commit b00344e
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 4 deletions.
6 changes: 3 additions & 3 deletions .azure-pipelines/azure-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
# CI pipeline for PSRule-pipelines

variables:
version: '2.4.0'
version: '2.5.0'
buildConfiguration: 'Release'
publish: 'true'
imageName: 'ubuntu-20.04'

# Use build number format, i.e. 2.4.0-B2106001
# Use build number format, i.e. 2.5.0-B2106001
name: $(version)-B$(date:yyMM)$(rev:rrr)

trigger:
Expand Down Expand Up @@ -146,7 +146,7 @@ stages:
action: edit
tag: '$(Build.SourceBranchName)'
releaseNotesSource: inline
releaseNotesInline: 'See [change log](https://github.com/Microsoft/PSRule-pipelines/blob/main/CHANGELOG.md)'
releaseNotesInline: 'See [change log](https://github.com/microsoft/PSRule-pipelines/blob/main/CHANGELOG.md)'
assetUploadMode: replace
addChangeLog: false
isPreRelease: false
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ See [upgrade notes][1] for helpful information when upgrading from previous vers

What's changed since v2.4.2:

- General improvements:
- Added outcome filtering parameter by @BernieWhite.
[#570](https://github.com/microsoft/PSRule-pipelines/issues/570)
- Engineering:
- Bump typescript to v4.8.4.
[#546](https://github.com/microsoft/PSRule-pipelines/pull/546)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any addi
## Maintainers
- [Bernie White](https://github.com/BernieWhite)
- [Sam Bell](https://github.com/ms-sambell)
## License
Expand All @@ -100,5 +101,4 @@ This project is [licensed under the MIT License][license].
[ps-rule-assert]: docs/tasks.md#ps-rule-assert
[ps-rule-install]: docs/tasks.md#ps-rule-install
[contribution guide]: https://github.com/Microsoft/PSRule-pipelines/blob/main/CONTRIBUTING.md
[change log]: https://github.com/Microsoft/PSRule-pipelines/blob/main/CHANGELOG.md
[license]: https://github.com/Microsoft/PSRule-pipelines/blob/main/LICENSE
4 changes: 4 additions & 0 deletions docs/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ steps:
baseline: string # Optional. The name of a PSRule baseline to use.
conventions: string # Optional. A comma separated list of conventions to use.
option: string # Optional. The path to an options file.
outcome: Fail, Pass, Error, Processed, Problem, All # Optional. Filters output to include results with the specified outcome.
outputFormat: None, Yaml, Json, Markdown, NUnit3, Csv # Optional. The format to use when writing results to disk.
outputPath: string # Optional. The file path to write results to.
path: string # Optional. The working directory PSRule is run from.
Expand Down Expand Up @@ -94,6 +95,9 @@ steps:
- **option**: The path to an options file.
By default, `ps-rule.yaml` will be used if it exists.
Configure this parameter to use a different file.
- **outcome**: Filters output to include results with the specified outcome.
Supported outcomes are `Fail`, `Pass`, `Error`, `Processed`, `Problem`, `All`.
Defaults to `Processed`.
- **outputFormat**: Output results can be written to disk in addition to the default output.
Use this option to determine the format to write results.
By default, results are not written to disk.
Expand Down
1 change: 1 addition & 0 deletions extension.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any addi
## Maintainers
- [Bernie White](https://github.com/BernieWhite)
- [Sam Bell](https://github.com/ms-sambell)
## License
Expand Down
9 changes: 9 additions & 0 deletions tasks/ps-rule-assertV2/powershell.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ param (
[Parameter(Mandatory = $False)]
[String]$Option = (Get-VstsInput -Name 'option'),

# Filters output to include results with the specified outcome.
[Parameter(Mandatory = $False)]
[String]$Outcome = (Get-VstsInput -Name 'outcome'),

# The output format
[Parameter(Mandatory = $False)]
[ValidateSet('None', 'Yaml', 'Json', 'Markdown', 'NUnit3', 'Csv', 'Sarif')]
Expand Down Expand Up @@ -268,6 +272,7 @@ Write-Host "[info] Using Conventions: $Conventions";
Write-Host "[info] Using InputType: $InputType";
Write-Host "[info] Using InputPath: $InputPath";
Write-Host "[info] Using Option: $Option";
Write-Host "[info] Using Option: $Outcome";
Write-Host "[info] Using OutputFormat: $OutputFormat";
Write-Host "[info] Using OutputPath: $OutputPath";

Expand All @@ -294,6 +299,10 @@ try {
$invokeParams['Option'] = $Option;
WriteDebug ([String]::Concat('-Option ', $Option));
}
if (![String]::IsNullOrEmpty($Outcome)) {
$invokeParams['Outcome'] = $Outcome;
WriteDebug ([String]::Concat('-Outcome ', $Outcome));
}
if (![String]::IsNullOrEmpty($Modules)) {
$moduleNames = $Modules.Split(',', [System.StringSplitOptions]::RemoveEmptyEntries);
$invokeParams['Module'] = $moduleNames;
Expand Down
4 changes: 4 additions & 0 deletions tasks/ps-rule-assertV2/powershell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ async function run() {
let input_baseline: string = task.getInput('baseline', /*required*/ false);
let input_conventions: string = task.getInput('conventions', /*required*/ false);
let input_option: string = task.getInput('option', /*required*/ false);
let input_outcome: string = task.getInput('outcome', /*required*/ false);
let input_outputFormat: string = task.getPathInput('outputFormat', /*required*/ false, /*check*/ false) || 'None';
let input_outputPath: string = task.getPathInput('outputPath', /*required*/ false, /*check*/ false);
let input_prerelease: boolean = task.getBoolInput('prerelease', /*required*/ false);
Expand Down Expand Up @@ -53,6 +54,9 @@ async function run() {
if (input_option !== undefined) {
contents.push(`$scriptParams['Option'] = '${input_option}'`);
}
if (input_outcome !== undefined) {
contents.push(`$scriptParams['Outcome'] = '${input_outcome}'`);
}
if (input_outputFormat !== undefined) {
contents.push(`$scriptParams['OutputFormat'] = '${input_outputFormat}'`);
}
Expand Down
8 changes: 8 additions & 0 deletions tasks/ps-rule-assertV2/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@
"defaultValue": "",
"helpMarkDown": "The path to an options file."
},
{
"name": "outcome",
"type": "string",
"label": "Outcome",
"required": false,
"defaultValue": "",
"helpMarkDown": "Filters output to include results with the specified outcome."
},
{
"name": "outputFormat",
"type": "pickList",
Expand Down

0 comments on commit b00344e

Please sign in to comment.