I've run into a problem using packer-plugin when the json I'm trying to use is in a subdirectory.
For example, my Jenkins job is cloning a git repo containing various packer configurations (e.g. centos-6.5, rhel-6.5, etc.). Each one is in a separate folder and has a template.json and a scripts directory.
Under the Packer post-build actions I specify Packer Template File "centos-6.5/template.json".
When I run the job I get the following error:
[workspace] $ /var/lib/jenkins/tools/biz.neustar.jenkins.plugins.packer.PackerInstallation/packer-0.7.5/packer build -only=virtualbox-iso -debug "/var/lib/jenkins/jobs/Packer build/workspace/centos-6.5/template.json"
4 error(s) occurred:
- Bad script 'scripts/base.sh': stat scripts/base.sh: no such file or directory
- Bad script 'scripts/vagrant.sh': stat scripts/vagrant.sh: no such file or directory
- Bad script 'scripts/virtualbox.sh': stat scripts/virtualbox.sh: no such file or directory
- Bad script 'scripts/cleanup.sh': stat scripts/cleanup.sh: no such file or directory
It appears that the relative paths (such as scripts/base.sh) in template.json are expected to be in the current directory (which is workspace/) although I'm calling workspace/centos-6.5/template.json.
So when I changed the script paths in the json to be "centos-6.5/scripts/base.sh" it ran successfully, however, I don't want to do that as it breaks the script if I then try to run it from within centos-6.5 (which is the recommended way).
It would be great to have a "Change directory" parameter for packer-plugin to change the working directory before calling packer.