8

I have been looking for a way to update AMI id in Jenkins EC2 plugin configuration after a packer build is run. After some digging, I found a promising way to do it IF the packer run is done by Jenkins itself, via postbuild groovy plugin (mind you, this remains to be tested, but looks good)

However I would like to be able to run the packer build anywhere, and have the resulting AMI id updated at Jenkins remotely, presumably via authenticated REST? Is that possible? Where would I start looking?

1
  • Not using it but I'd tackle the problem with a periodic job on Jenkins itself getting the ami id from aws ec2 describe-images
    – Tensibai
    Mar 14 '17 at 22:30
6

The PR you are linking to contains a link to a python script that does exactly this, since you can run that script from anywhere you can access your Jenkins server.

0
3

Updated the python script from the PR above with:

  • CSRF support to work better with Jenkins 2.x
  • full support for private Jenkins jobs

Also I wrote up some usage instructions.

1

For me, the best place to start is to have at the end of your packer.json a call to the manifest post-processor.

This will contain the full details of the AMI that you have created in JSON format.

eg "artifact_id": "us-west-1:ami-XXXXXXXX",

This can then be read and acted on by any tooling of your choice.

Source: https://www.packer.io/docs/post-processors/manifest.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.