Windows 2019 Self Hosted Runner Fails on Warnings

Our actions workflow runs successfully on both Windows 10 Self Hosted Runner and also on Github Hosted Runner [windows-2019]

When running on our self-hosted Windows 2019 Server, any warning occurring during the node build process (for an Angular front-end) causes “Error: process completed with exit code 1”

Is it possible to stop warnings from failing the actions workflow run?

We tried

  • Using powershell 7 (pwsh) to run the workflow commands
  • in workflow file, Set env variable CI: false
  • in windows 2019 - powershell , set $WarningPreference= ‘SilentlyContinue’

but the warning still stops the run.

You could set jobs.<job_id>.continue-on-error or jobs.<job_id>.steps[*].continue-on-error to true to ignore any errors, but that’s probably not what you want.

Do you execute set $WarningPreference='SilentlyContinue' in the same run block and also for any sub-shells if there are any? If so, then my guess is that whatever causes the process to exit with a non-zero code isn’t actually caused by what PowerShell considers a warning. You could try set $ErrorActionPreference='SilentlyContinue' to check if that makes a difference.

I guess that whatever tool you run actually exits with code 1 on its own terms, which makes the job fail. You should check if the tool has any command line option to modify this behavior (exit cleanly as long as there are only warnings). As a last resort, you could try to ignore the exit code by catching the error, e.g. like

Try { command }
Catch [System.Exception] { "Caught exception" }
Finally { $error.Clear() }