Running Packer from Jenkins - nothing appearing in console

3,958 views
Skip to first unread message

Yannis Lionis

unread,
Jul 2, 2015, 5:22:47 AM7/2/15
to packe...@googlegroups.com
I'm running packer in a Jenkins build by executing "packer build template.file" in a Shell build step.

My problem is that the output of the command that appears when I execute this in my dev environment is nowhere to be found. Instead, the Jenkins build console contains this:

+ packer build template.file
0 0
Finished: SUCCESS

On top of it, the packer build actually fails, but the Jenkins build shows successful.

I subsequently discovered the Packer Jenkins plugin and installed it. Same issue, the output in the Jenkins console does not contain the information displayed when I execute manually, it looks lie this:

$ /var/lib/jenkins/packer/packer build /var/lib/jenkins/workspace/template.file
FATAL: Execution failed: /var/lib/jenkins/packer/packer build /var/lib/jenkins/workspace/template.file
Finished: FAILURE
Build step 'Packer' marked build as failure
Finished: FAILURE

Any ideas?

Yannis


Dan Tran

unread,
Jul 2, 2015, 12:57:46 PM7/2/15
to packe...@googlegroups.com
File file a bug, packer should return none zero code

I am seeing the same issue

Thanks

-D

Piotr Mitoraj

unread,
Jul 2, 2015, 5:46:41 PM7/2/15
to packe...@googlegroups.com
Hi

This is what I do in 'execute shell' build step before I run packer:
export PACKER_LOG=1
export PACKER_LOG_PATH=$WORKSPACE/packer.log
echo "packer log path:" $PACKER_LOG_PATH

I think though that you should be able to see the packer output anyway.

As for the second issue I never actually experienced a green build despite packer failure. I am not using any packer jenkins plugin.

Below sample Console Output from Jenkins build
..checking out code..
[packer-base_build_vmware] $ /bin/sh /tmp/hudson7245981517662937540.sh
packer log path: /home/jenkins/workspace/packer-base_build_vmware/packer.log
/opt/packer/packer build -only=vmware-iso -force -var vmx_template=/home/jenkins/workspace/packer-base_build_vmware/packer_conf/template.vmx -var-file=/home/jenkins/workspace/packer-base_build_vmware/packer_conf/vmware_vars.json /home/jenkins/workspace/packer-base_build_vmware/packer_conf/packer_vm.json
 [1;32mvmware-iso output will be in this color. [0m

 [1;32mWarnings for build 'vmware-iso':
 [0m
 [1;32m* A checksum type of 'none' was specified. Since ISO files are so big,
a checksum is highly recommended. [0m
 [1;32m [0m
 [1;32m==> vmware-iso: Downloading or copying ISO [0m
 [0;32m    vmware-iso: Downloading or copying: file:///opt/packer/rhel-server-6.6-x86_64-boot.iso [0m
 [1;32m==> vmware-iso: Deleting previous output directory... [0m
 [1;32m==> vmware-iso: Uploading ISO to remote machine... [0m
 [1;32m==> vmware-iso: Creating virtual machine disk [0m
 [1;32m==> vmware-iso: Building and writing VMX file [0m
 [1;32m==> vmware-iso: Starting HTTP server on port 8069 [0m
 [1;32m==> vmware-iso: Registering remote VM... [0m
 [1;32m==> vmware-iso: Starting virtual machine... [0m
 [1;32m==> vmware-iso: Waiting 5s for boot... [0m
 [1;32m==> vmware-iso: Connecting to VM via VNC [0m
...

Here I found the failed log when disk could not be created because I ran out of disk space, packer failed and build was red:
packer-base_build_vmware] $ /bin/sh /tmp/hudson8243131398042465789.sh
packer log path: /home/jenkins/workspace/packer-base_build_vmware/packer.log
/opt/packer/packer build -only=vmware-iso -force -var vmx_template=/home/jenkins/workspace/packer-base_build_vmware/packer_conf/template.vmx -var-file=/home/jenkins/workspace/packer-base_build_vmware/packer_conf/vmware_vars.json /home/jenkins/workspace/packer-base_build_vmware/packer_conf/packer_vm.json
 [1;32mvmware-iso output will be in this color. [0m

 [1;32mWarnings for build 'vmware-iso':
 [0m
 [1;32m* A checksum type of 'none' was specified. Since ISO files are so big,
a checksum is highly recommended. [0m
 [1;32m [0m
 [1;32m==> vmware-iso: Downloading or copying ISO [0m
 [0;32m    vmware-iso: Downloading or copying: file:///opt/packer/rhel-server-6.6-x86_64-boot.iso [0m
 [1;32m==> vmware-iso: Uploading ISO to remote machine... [0m
 [1;32m==> vmware-iso: Creating virtual machine disk [0m
 [1;31m==> vmware-iso: Error creating disk: 'vmkfstools -c 100000M -d zeroedthick -a lsilogic /vmfs/volumes/packer.io/packer_base/disk.vmdk'
==> vmware-iso: 
==> vmware-iso: Stdout: 
==> vmware-iso: 
==> vmware-iso: Stderr: Failed to create virtual disk: There is not enough space on the file system for the selected operation (13).
==> vmware-iso: [0m
 [1;32m==> vmware-iso: Deleting output directory... [0m
 [1;31mBuild 'vmware-iso' errored: Error creating disk: 'vmkfstools -c 100000M -d zeroedthick -a lsilogic /vmfs/volumes/packer.io/packer_base/disk.vmdk'

Stdout: 

Stderr: Failed to create virtual disk: There is not enough space on the file system for the selected operation (13).
 [0m

==> Some builds didn't complete successfully and had errors:
--> vmware-iso: Error creating disk: 'vmkfstools -c 100000M -d zeroedthick -a lsilogic /vmfs/volumes/packer.io/packer_base/disk.vmdk'

Stdout: 

Stderr: Failed to create virtual disk: There is not enough space on the file system for the selected operation (13).


==> Builds finished but no artifacts were created.
Build step 'Execute shell' marked build as failure
Skipped archiving because build is not successful
Warning: you have no plugins providing access control for builds, so falling back to legacy behavior of permitting any downstream builds to be triggered
Notifying upstream projects of job completion
Finished: FAILURE

Regards
Piotr

--
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 packer-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/a65f3c6d-69ea-43df-bdad-421b97076de4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Yannis Lionis

unread,
Jul 7, 2015, 4:49:53 AM7/7/15
to packe...@googlegroups.com
Thanks both - I got to the bottom of this...

The build itself was failing due to AWS credentials (which I was aware of). Once I fixed that, the console output actually started to appear. If there is a failure further along everything is displayed correctly in the console log, but for some reason the authentication error does not. Oh well.

Yannis

Alvaro Miranda Aguilera

unread,
Jul 7, 2015, 5:39:14 PM7/7/15
to packe...@googlegroups.com
If I understand correctly, your aws build was failing and you got no
errors from packer for those autentication errors?

can you open an issue on github?

https://github.com/mitchellh/packer/issues
> https://groups.google.com/d/msgid/packer-tool/e32799e2-415b-4772-b8e6-489d20d65224%40googlegroups.com.

Yannis Lionis

unread,
Jul 8, 2015, 4:39:37 AM7/8/15
to packe...@googlegroups.com
I have made some more discoveries, not convinced it's a packer plugin bug yet...

When I run the build in Jenkins I see:

[job-name] $ /var/lib/jenkins/tools/biz.neustar.jenkins.plugins.packer.PackerInstallation/Packer/packer build /var/lib/jenkins/workspace/job-name/project-name/base.json
FATAL: Execution failed: /var/lib/jenkins/tools/biz.neustar.jenkins.plugins.packer.PackerInstallation/Packer/packer build /var/lib/jenkins/workspace/job-name/project-name/base.json

Finished: FAILURE Build step 'Packer' marked build as failure Finished: FAILURE

When I run it from the command line as someone other than the Jenkins user I get:

[centos@jenkins project-name]$ packer build base.json 

amazon-ebs output will be in this color.


==> amazon-ebs: Prevalidating AMI Name...

==> amazon-ebs: Inspecting the source AMI...

==> amazon-ebs: Creating temporary keypair: packer XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX

==> amazon-ebs: Deleting temporary keypair...

==> amazon-ebs: Error cleaning up keypair. Please delete the key manually:

Build 'amazon-ebs' errored: Error creating temporary keypair: UnauthorizedOperation: You are not authorized to perform this operation.

status code: 403, request id: []


==> Some builds didn't complete successfully and had errors:

--> amazon-ebs: Error creating temporary keypair: UnauthorizedOperation: You are not authorized to perform this operation.

status code: 403, request id: []


==> Builds finished but no artifacts were created.


But when I run it from the command line as the jenkins user, surprisingly I get:


bash-4.2$ packer build base.json 

[HANGS!]



When I say it hangs, I mean that there is no output, but ps shows the process running for as long as I leave it, consuming no CPU and no memory. 

I am fully aware that credentials need to be set up separately per user, these builds were all intentionally made to fail with missing credentials.

This leads me to think that there is something about the Jenkins user that loses the output. I've already made sure that it has the same shell as the other user (/bin/bash). Is there something else about the Unix user that could be causing this or am I barking up the wrong tree?

Alvaro Miranda Aguilera

unread,
Jul 8, 2015, 5:23:53 AM7/8/15
to packe...@googlegroups.com
as the jenkins user can you do

id
which packer
ls -al <directory_of_packer>

also will help

PACKER_LOG=1 packer build base.json

and

strace -f packer build base.json

last 2 will generate insane number of log :D

so a gist is welcome
> https://groups.google.com/d/msgid/packer-tool/0e255b5b-e8fe-4232-9628-8189f030c5a8%40googlegroups.com.

Yannis Lionis

unread,
Jul 8, 2015, 6:25:19 AM7/8/15
to packe...@googlegroups.com
:'-(

which packer revealed the truth:

bash-4.2$ which packer

/sbin/packer

bash-4.2$ ls -al /sbin/packer

lrwxrwxrwx. 1 root root 15 Sep 29  2014 /sbin/packer -> cracklib-packer

bash-4.2$ 


Needless to say the path for the other user points to the actual packer installation. And when I actually execute the correct binary I do get output.


Thank you for the help and apologies for the stupid issue that had nothing to do with packer itself...

Alvaro Miranda Aguilera

unread,
Jul 8, 2015, 5:44:58 PM7/8/15
to packe...@googlegroups.com
Hey, all good

In some linux, the path include ~/bin

so if you create /home/jenkins/bin

and put all the packer stuff there shoud work

if doesn't check in jenking's .bash_profile or .bashrc

you can update the PATH there, and be sure to export it

Alvaro
> https://groups.google.com/d/msgid/packer-tool/3dcbcee5-4875-4e6c-b6c2-89930028cf26%40googlegroups.com.

gopi krishna

unread,
May 27, 2019, 12:05:42 PM5/27/19
to Packer

Hi Yannis Lionis

See initial question is correct ...not able to build packer template on jenkins ..then quetion deviated and author also some where deviated
Thanks
--Gopi

gopi krishna

unread,
May 27, 2019, 12:07:02 PM5/27/19
to Packer
What the solution still this issue is persists .
Thanks
--GOpi

Tarun Mittal

unread,
Jun 13, 2020, 12:39:06 AM6/13/20
to Packer

I don't about why this issue is coming, but what I did in Jenkins job shell execution:-
1 . which packer -- in this, it is running from /usr/sbin/packer which is pointing to ---> cracklib-packer.
2.  but I installed the packer and copy that to /usr/bin/ directory, so in Jenkins job I did /usr/bin/packer to run any packer command in my Jenkins job. In my case, it is working.


Thanks, @Yannas


On Thursday, July 2, 2015 at 2:52:47 PM UTC+5:30, Yannis Lionis wrote:

Rickard von Essen

unread,
Jun 14, 2020, 5:37:12 AM6/14/20
to packe...@googlegroups.com

Note: This message is the property of HashedIn and its subsidiaries. It may be legally privileged and/or confidential and is intended only for the use of the addressee(s). No addressee should forward, print, copy, or otherwise reproduce this message in any manner that would allow it to be viewed by any individual not originally listed as a recipient. If the reader of this message is not the intended recipient, you are hereby notified that any unauthorized disclosure, dissemination, distribution, copying or the taking of any action in reliance on the information herein is strictly prohibited. If you have received this communication in error, please immediately notify the sender and delete this message.

--
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.
 

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 packer-tool...@googlegroups.com.

Tarun Mittal

unread,
Jun 14, 2020, 5:40:30 AM6/14/20
to packe...@googlegroups.com
Thanks for sharing this link is useful.

Reply all
Reply to author
Forward
0 new messages