I am working on a set of build scripts which are called from a ubuntu hosted CI environment. The powershell build script calls jest
via react-scripts
via npm
. Unfortunately jest doesn't use stderr
correctly and writes non-errors to the stream.
I have redirected the error stream using 3>&1 2>&1
and this works fine from just powershell core ($LASTEXITCODE
is 0 after running, no content from stderr is written in red).
However when I introduce docker via docker run
, the build script appears to not behave and outputs the line that should be redirected from the error stream in red (and crashes). i.e. something like: docker : PASS src/App.test.js. Error: Process completed with exit code 1.
.
Can anyone suggest what I am doing wrong? because I'm a bit stumped. I include the sample PowerShell call below:-
function Invoke-ShellExecutable
{
param (
[ScriptBlock]
$Command
)
$Output = Invoke-Command $Command -NoNewScope | Out-String
if($LASTEXITCODE -ne 0) {
$CmdString = $Command.ToString().Trim()
throw "Process [$($CmdString)] returned a failure status code [$($LASTEXITCODE)]. The process may have outputted details about the error."
}
return $Output
}
Invoke-ShellExecutable {
($env:CI = "true") -and (npm run test:ci)
} 3>&1 2>&1