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
Host platform
MacOS Sierra 10.12.4
Debug log output from PACKER_LOG=1 packer build template.json
.
https://gist.github.com/matt-richardson/71dfe5ee0f824960774940314d9b51c9
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.