Skip to content

Task randomly fails with 'Error code 5'  #385

@dkaubar

Description

@dkaubar

Description of the issue

Task randomly fails with 'Error code 5' when running a scan on bicep templates. I say randomly, since rerun of same task (identical configuration) can succeed, or fail a few more times before eventually succeeding.
Task runs for 3-5 mins before failing

Configuration
We do not run "Install PSRule module" task prior to this task. ps-rule-assert@1 is a first task in a job.
Job is running on Microsoft-hosted agent
Image: windows-latest

Yaml configuration of the extension.

      - task: ps-rule-assert@1
        displayName: "Run PSRule scan"
        inputs:
          path: "$(System.DefaultWorkingDirectory)"
          inputType: "inputPath"
          inputPath: "$(projectDirectory)/devops/infrastructure/bicep/*.bicep"
          source:
          modules: "PSRule.Rules.Azure"
          outputFormat: "NUnit3"
          outputPath: "$(Pipeline.Workspace)/PSRule/ps-rule-results.xml"

Expected behaviour

Task to succeed in providing scan results

Error output

Last logs before error:
From repository: {Repo-name}
on : refs/pull/6814/merge
at : 36f6dae96fa568f1c1349feb42dc7c3080cb8321

Then error:

##[error]Exit code 5 returned from process: file name 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe', arguments '-NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". ([scriptblock]::Create('if ([Console]::InputEncoding -is [Text.UTF8Encoding] -and [Console]::InputEncoding.GetPreamble().Length -ne 0) { [Console]::InputEncoding = New-Object Text.UTF8Encoding $false } if (!$PSHOME) { $null = Get-Item -LiteralPath ''variable:PSHOME'' } else { Import-Module -Name ([System.IO.Path]::Combine($PSHOME, ''Modules\Microsoft.PowerShell.Management\Microsoft.PowerShell.Management.psd1'')) ; Import-Module -Name ([System.IO.Path]::Combine($PSHOME, ''Modules\Microsoft.PowerShell.Utility\Microsoft.PowerShell.Utility.psd1'')) }')) 2>&1 | ForEach-Object { Write-Verbose $_.Exception.Message -Verbose } ; Import-Module -Name 'D:\a\_tasks\ps-rule-assert_8804fc31-b62f-4d49-b2a1-c80dc0879dae\1.0.2201013\ps_modules\VstsTaskSdk\VstsTaskSdk.psd1' -ArgumentList @{ NonInteractive = $true } -ErrorAction Stop ; $VerbosePreference = 'SilentlyContinue' ; $DebugPreference = 'SilentlyContinue' ; Invoke-VstsTaskScript -ScriptBlock ([scriptblock]::Create('. ''D:\a\_tasks\ps-rule-assert_8804fc31-b62f-4d49-b2a1-c80dc0879dae\1.0.2201013\powershell.ps1'''))"'.

Task in use and version:

  • Task: ps-rule-assert
  • Version: SHOULD be 1.5.0, we have latest version installed. DevOps logs mention v 1.0.2201013, not sure what's that

From DevOps extension details:
Installed version
1.5.0 (Latest)

From task execution log:
Task : PSRule analysis
Description : Run analysis with PSRule.
Version : 1.0.2201013

Additional context

Additional logs:

 Checking module: PSRule.Rules.Azure
  - Installing module
  - Using version: 1.14.3

[info] Using Version: 2.0.1
[info] Using PWD: D:\a\_tasks\ps-rule-assert_8804fc31-b62f-4d49-b2a1-c80dc0879dae\1.0.2201013
[info] Using Path: D:\a\1\s
[info] Using Source: D:\a\1\s
[info] Using Baseline: 
[info] Using Conventions: 
[info] Using InputType: inputPath
[info] Using InputPath: D:\a\1\s\projectName\devops\infrastructure\bicep\*.bicep
[info] Using OutputFormat: NUnit3
[info] Using OutputPath: D:\a\1\PSRule\ps-rule-results.xml

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions