Hello i see test.sh but you mention run.bat, so I assume you run packer in
windows, and want to capture the error?


lets go on stages

Can you run the packer in debug mode so we can confirm the exit code of
that part is fine?

set PACKER_LOG=1

then run the build

share a gist (gist.github.com)

and if you can run in your run.bat something like this after the packer
run:
if %errorlevel% neq 0 exit /b %errorlevel%

Should help.

Thanks
Alvaro

On Thu, Apr 13, 2017 at 9:49 AM, Becky <[email protected]> wrote:

> Hi,
>
>
> I am using packer 1.0.0 on Windows 10.
>
>
>
> *Run.bat*
>
>
>
> Packer build –only mybuilder –var-file=variables_file.json
>
> Echo %errorlevel%
>
> <<This always show 0 even if my shell scripts exited with returned code 1.
>
> Is this expected behavior, if so then how can one catch the errors of
> SHELL and take action in run.bat file ?>>
>
>
>
> *variables_file.json*
>
>
>
> {
>
>     "builders": [{
>
>         "type": "null",
>
>         "name": " mybuilder",
>
>         "ssh_host": "{{user ` host`}}",
>
>         "ssh_username": "{{user ` username`}}",
>
>         "ssh_password": "{{user ` password`}}",
>
>         "ssh_timeout" : "{{user `esxi_ssh_timeout`}}"
>
>     }],
>
>     "provisioners": [{
>
>         "type": "shell",
>
>         "only": ["mybuilder"],
>
>         "scripts": [
>
>             "script/testESXi.sh"
>
>         ]
>
>     }
>
>     ]
>
> }
>
>
>
> *testESXi.sh*
>
>
>
> #!/bin/sh
>
>
>
> exit 1;
>
>
> Regards,
>
> Becky
>
> --
> This mailing list is governed under the HashiCorp Community Guidelines -
> https://www.hashicorp.com/community-guidelines.html. Behavior in
> violation of those guidelines may result in your removal from this mailing
> list.
>
> GitHub Issues: https://github.com/mitchellh/packer/issues
> IRC: #packer-tool on Freenode
> ---
> You received this message because you are subscribed to the Google Groups
> "Packer" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/packer-tool/82f04172-898b-4dd3-8184-f0202aa9bf36%40googlegroups.com
> <https://groups.google.com/d/msgid/packer-tool/82f04172-898b-4dd3-8184-f0202aa9bf36%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Alvaro

-- 
This mailing list is governed under the HashiCorp Community Guidelines - 
https://www.hashicorp.com/community-guidelines.html. Behavior in violation of 
those guidelines may result in your removal from this mailing list.

GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
--- 
You received this message because you are subscribed to the Google Groups 
"Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/packer-tool/CAHqq0ey7-ZT%3DbnqwhmyCTvMHVXjK7ra%3DDrWM%3D1gf9z2RbE%3DGYQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to