Packer: Error exit code not set if post-processor not found

Created on 9 Apr 2017  ยท  5Comments  ยท  Source: hashicorp/packer

I added a new post-processor (this one) to my packer template, tested it, and then committed it to git so it could build on my build server.

I hadn't installed the plugin on the build server, so it errored, but it exited with exit code 0, indicating success, which threw me. I would have expected it to return a non-zero exit code here.

$ packer --version
0.12.3
bug core

All 5 comments

Hmm, looks like we explicitly ignore any errors we have when creating a build

see https://github.com/hashicorp/packer/blob/81522dc/command/build.go#L65-L68

I'm assuming this is so we can get all of the errors before exiting.

the obvious solution is to set an error flag and then exit with the appropriate code if it's set, but that changes the behavior of packer. Right now, Packer will try to run as many builds as possible. It's debatable if this behavior is correct, but it would be a backwards compatibility breaking change.

{
    "builders": [
        {
            "commit": true,
            "image": "ubuntu:xenial",
            "type": "docker",
            "name": "docker-1"
        },
        {
            "commit": true,
            "image": "ubuntu:xenial",
            "type": "docker",
            "name": "docker-2"
        }
    ],
    "post-processors": [
        {
            "type": "vagrant-s3",
            "only": ["docker-1"]
        }
    ]
}

I'll try to get some folks to weigh in here before making a decision

consensus seems to be that we should fail everything if one would fail

I met the same issue with an unknown builders, not only post-processors.
This causes false positive builds on CI server, and makes troubleshooting more complicated.

This was fixed in earlier releases and now whenever there's an error during the building process the right error code is returned.
See here: https://github.com/hashicorp/packer/blob/master/command/build.go#L170
Also, I've tested it locally and packer returned exit code 1.

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jesse-c picture jesse-c  ยท  3Comments

wduncanfraser picture wduncanfraser  ยท  3Comments

brettswift picture brettswift  ยท  3Comments

sourav82 picture sourav82  ยท  3Comments

znerd picture znerd  ยท  3Comments