Skip to content

Commit

Permalink
Added outcome filtering #570
Browse files Browse the repository at this point in the history
  • Loading branch information
BernieWhite committed Oct 17, 2022
1 parent 4743c95 commit e95ec92
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 3 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
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 e95ec92

Please sign in to comment.