I’m building a google compute image with Packer and Ansible-Remote provisioner. Specifically, the playbooks will run as a non-root user as mentioned in the script (
But, the actual problem is, while I’m running this packer script via Jenkins pipeline, the jobs were running as a root user and could not consume the exported environment variables.
So, I tried to run the
packer build command as below and successfully build the image, but could not consume the NEXUS credentials which is in the root user’s env variable exported by Jenkins.
sudo -iu cloud_user -- bash -c 'packer build -var-file=packer_vars.json app_build.json'
Any possible solution for the above-stated issue other than changing the DEFAULT user in Jenkins config, as this is not possible due to some other reason?