PowerShell provisioner ignores some type of errors although $ErrorActionPreference = 'Stop' is set and there is [INFO] 259 bytes written for 'stderr' log when docker builder and windows container is used. There is a related issue on PowerShell provisioner https://github.com/hashicorp/packer/issues/4916, however this issue can be solved by putting $ErrorActionPreference = 'Stop' to the top of the scripts(like in the simplified packer buildfile) when googlecompute builder is used but same solution doesn't work for docker builder.
Helpful(?) notes
When I tried to replicate what docker provisioner does by running same command(docker exec -i ${container.id} powershell (${command})) from my local, it shows the same output and sets $LastExitCode to 1 on my local. So, I thought there could be some issues when checking errors after running commands on powershell.
Hi Packer team,
Overview of the Issue
PowerShell provisioner ignores some type of errors although
$ErrorActionPreference = 'Stop'
is set and there is[INFO] 259 bytes written for 'stderr'
log when docker builder and windows container is used. There is a related issue on PowerShell provisioner https://github.com/hashicorp/packer/issues/4916, however this issue can be solved by putting$ErrorActionPreference = 'Stop'
to the top of the scripts(like in the simplified packer buildfile) when googlecompute builder is used but same solution doesn't work for docker builder.Helpful(?) notes
When I tried to replicate what docker provisioner does by running same command(
docker exec -i ${container.id} powershell (${command})
) from my local, it shows the same output and sets$LastExitCode
to 1 on my local. So, I thought there could be some issues when checking errors after running commands on powershell.Reproduction Steps
Run packer build.
Plugin and Packer version
packer: 1.8.4 plugin: 1.0.8
Simplified Packer Buildfile
Operating system and Environment details
Windows 11 Laptop, Docker version 20.10.22, build 3a2c30b
Log Fragments and crash.log files