Hello
So packer expect exit code 0 to assume all went fine.
It seems when you run the command it exit with error code 3221225781
If I do a script file a.cmd
copy a b
and I run it like
cmd.exe /c a.cmd
Z:\t>copy a b
1 file(s) copied.
It gives me:
Z:\t>echo %errorlevel%
0
Can you run something like that?
file a need to exits
Alvaro
On Wed, Jul 19, 2017 at 1:38 AM, James Elmes <[email protected]>
wrote:
> alright i got a bit further now after adding the sh.exe to the same
> location from where im running packer.
>
> now im getting the below, doesn't seem to matter what script i run but
> here is the result:
>
> 2017/07/19 09:04:46 packer.exe: 2017/07/19 09:04:44 starting local
> command: cmd.exe /c scripts/copy.cmd
> 2017/07/19 09:04:46 [INFO] (telemetry) ending shell-local
> 2017/07/19 09:04:46 [INFO] (telemetry) found error: Erroneous exit code
> 3221225781 while executing script: scripts/copy.cmd
> Please see output above for more information.
> 2017/07/19 09:04:46 Deleting original artifact for build 'null'
> 2017/07/19 09:04:46 ui error: Build 'null' errored: 1 error(s) occurred:
> * Post-processor failed: Erroneous exit code 3221225781 while executing
> script: scripts/copy.cmd
> 2017/07/19 09:04:46 Builds completed. Waiting on interrupt barrier...
> 2017/07/19 09:04:46 machine readable: error-count []string{"1"}
> 2017/07/19 09:04:46 ui error:
> ==> Some builds didn't complete successfully and had errors:
> 2017/07/19 09:04:46 machine readable: null,error []string{"1 error(s)
> occurred:\n\n* Post-processor failed: Erroneous exit code 3221225781 while
> executing script: scripts/copy.cmd\n\nPlease see output above for more
> information."}
> 2017/07/19 09:04:46 ui error: --> null: 1 error(s) occurred:
> * Post-processor failed: Erroneous exit code 3221225781 while executing
> script: scripts/copy.cmd
> Please see output above for more information.
> 2017/07/19 09:04:46 ui:
>
>
> It is just a simple .CMD command to copy a file, when i run in CMD it
> works fine as below.
> C:\PACKER\OPTUSgit\scripts>copy.cmd
> C:\PACKER\OPTUSgit\scripts>cmd.exe /c copy c:\tools\winscp.ini c:\temp
> 1 file(s) copied.
>
> Below is my test template, just encase i am doing something wrong but i
> doubt it:
> {
>
> "builders":[{
> "type": "null",
> "communicator":"winrm",
> "winrm_host": "10.1.1.10",
> "winrm_username":"jimmy",
> "winrm_password":"password",
> "winrm_port":"5985",
> "winrm_timeout":"24h"
>
> }],
>
> "provisioners": [
>
> {
> "type": "windows-shell",
> "inline": "shutdown /s /t 1 /f /d p:4:1 /c \"Packer Shutdown Stage 1\""
>
> }
> ],
> "post-processors":[
> {
> "type":"shell-local",
> "execute_command": "cmd.exe /c {{.Script}}",
> "script": "scripts/copy.cmd"
>
>
>
> any further assistance would be appreciated..
>
> On Wednesday, 19 July 2017 00:17:16 UTC+10, Alexander Lehmann wrote:
>>
>> It should work to run a powershell script with the execute_command which
>> renames the file to .ps1 and runs it.
>>
>> You can either run packer from the cmder screen or you have to put the
>> dir where the sh.exe command is present is included in the search path in
>> Powershell.
>>
>>
>> On Tuesday, July 18, 2017 at 10:06:28 AM UTC+2, James Elmes wrote:
>>>
>>> Thanks for your reply and explaining {{.script}.
>>>
>>> I don't sh, I have just installed CMDER but not sure what to do next to
>>> be honest.. not being a linux guru
>>>
>>> do i have to run the packer commands from this? if so wouldn't they be
>>> completely different? i currently run using powershell
>>>
>>> Example:
>>> $env:PACKER_ESXI_VNC_PROBE_TIMEOUT="30s"
>>> $env:PACKER_LOG="1"
>>> $env:PACKER_LOG_PATH="packerlog.txt"
>>> Start-Process c:\packer\packer_config\packer.exe -ArgumentList "build
>>> -var-file esxi_variables.json windowsonesxi4.json" -Wait -NoNewWindow
>>>
>>> On Saturday, 15 July 2017 03:32:55 UTC+10, Megan Marsh wrote:
>>>>
>>>> Hi James,
>>>>
>>>> Coming back online after a couple days away so apologies if you've
>>>> already figured this out and I'm being redundant.
>>>>
>>>> The operation definitely depends on sh being installed, so installing
>>>> that will very likely solve your issue.
>>>>
>>>> {{.Script}} is a Packer internal variable that references the location
>>>> of the script in the tmp folder on the guest vm. This is implied in the
>>>> docs, but it could probably be clearer that you can actually use
>>>> {{.Script}} in your packer template as a way of referring to that script's
>>>> absolute path.
>>>>
>>>> I'm guessing the reason the code Rickard pasted isn't working for you
>>>> "out of the box" is because you don't have shell installed and you didn't
>>>> apply the diff from my referenced comment beforehand (
>>>> https://github.com/hashicorp/packer/compare/shell_4140)? As you can
>>>> see in there, Packer currently hardcodes the command as assuming you've got
>>>> shell: `localCmd := exec.Command("sh", "-c", cmd.Command)`.
>>>>
>>>> Hope this helps! We've definitely got some kinks to work out on Windows.
>>>>
>>>> On Wednesday, July 12, 2017 at 4:25:47 AM UTC-7, James Elmes wrote:
>>>>>
>>>>> thanks again Alex, i didn't really want to increase the moving parts
>>>>>>>>> involved with the packer process but i may give this a go.
>>>>>>>>>
>>>>>>>>
>>>>> the other option is to just run it with the run command like the
>>>>> below.
>>>>>
>>>>> $env:PACKER_ESXI_VNC_PROBE_TIMEOUT="30s"
>>>>> $env:PACKER_LOG="1"
>>>>> $env:PACKER_LOG_PATH="packerlog.txt"
>>>>> Start-Process c:\packer\packer_config\packer.exe -ArgumentList "build
>>>>> -var-file esxi_variables.json windowsonesxi4.json" -Wait -NoNewWindow
>>>>> ovftool.exe -tt=ova vi://root:[email protected].
>>>>> 11/Windows2012R2v1-2017-07 ovaexport1112.ova
>>>>>
>>>>> ill let you know how this goes
>>>>>
>>>>> regards
>>>>>
>>>>> James
>>>>>
>>>> --
> 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/6c9563e2-d2ae-4928-8739-4575acf764f5%40googlegroups.com
> <https://groups.google.com/d/msgid/packer-tool/6c9563e2-d2ae-4928-8739-4575acf764f5%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/CAHqq0ew7ZHUnXd7yvCmPxJiM68QkaMR2v_BKNWxncT2mYEY8%3Dw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.