packer-community / packer-windows-plugins

A suite of Packer plugins for provisioning Windows machines
112 stars 20 forks source link

Properly handle Powershell Exit Codes #36

Closed mefellows closed 9 years ago

mefellows commented 9 years ago

Issue #34 introduces a long known-issue with non-zero exit codes preventing a Packer build from failing fast. This feature addresses this situation in the non-elevated command runner (elevated command already handles this), and also adds a template parameter to allow user to specify valid exit codes in cases non-zero codes are in fact expected (such as installing common software that return other known exit codes).

See https://gist.github.com/mefellows/32e5ca354a6c3255bc16 for an Integration test case

@dylanmei Would be interested in your feedback on this one before we integrate into master.

pall-valmundsson commented 9 years ago

I'm wondering if the same shouldn't apply to the elevated execution command.

mefellows commented 9 years ago

Actually, the elevated command already handles exit codes from my testing (see updated gist).

pall-valmundsson commented 9 years ago

Yeah, I see there's a different command run for elevated scripts.

I'm new to powershell so I'm no expert but this exit code issue seems to be a huge mess. Sometimes it seems to work and sometimes not.

mefellows commented 9 years ago

A PR for #30 is forthcoming. In the interest of having a clean state of affairs and getting some more eyes I'd like to get this in beforehand, and push out another pre-release version.