-
Notifications
You must be signed in to change notification settings - Fork 690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the ability to programatically update the AMI ID using Groovy #154
Conversation
This is a proposed fix for JENKINS-28268 Our Use Case: At FreshBooks, we have multiple Packer jobs that build new Jenkins build workers as and when the underlying repos are updated. The problem with this approach (currently) is that after this is done, someone needs to go in and manually update the Jenkins configuration to point to the new AMI ID. Proposed Fix: With this approach, we could trigger a post-build Groovy script to automatically go in and update the relevant AMI ID without us having to do this manually. Groovy Example: Here is an example Groovy script that demonstrates getting and setting the AMI ID programatically: ``` import jenkins.model.*; import hudson.plugins.ec2.*; Jenkins.instance.clouds.each { if (it.displayName == 'test-cloud') { it.getTemplates().each { println(it.displayName) println("Print current AMI id : " + it.getAmi()) it.setAmi("ami-4567") println("Print current AMI id : " + it.getAmi()) } } } Jenkins.instance.save() ``` Reference: https://issues.jenkins-ci.org/browse/JENKINS-28268 [FIXED JENKINS-28268]
4649eb8
to
7af6c1c
Compare
Jenkins » ec2-plugin #123 SUCCESS |
Jenkins » ec2-plugin #124 FAILURE |
Thank you for a pull request! Please check this document for how the Jenkins project handles pull requests |
This solution fixes the exact same issue we're having at NewVoiceMedia where we have a number of CI Packer Jobs creating base AMI's for existing AMI templates in Jenkins. We're also having to manually update the configuration with the new AMI IDs created from the packer jobs. This will be a great addition hopefully to get merged soon. Thanks |
+1 this would be great! thanks! |
Add the ability to programatically update the AMI ID using Groovy
Thank you for merging this so quickly! 😄 |
Thanks for your contribution. Sent from my iPhone
|
+1 At Kenshoo we update the ami manually(After a packer job that built the slaves) till now. Thanks for this PR! |
If this is helpful to anyone else, this is the python script we use to cleanup and update the AMI IDs. https://gist.github.com/marvinpinto/a6c9b5119d418a65d489 |
Thanks again @marvinpinto 👍 |
@francisu is there a release planned soon ? |
Just did the release, should be available in a day or so. |
Got it, thank you! |
The script is a bit out of date and didn't work for me so I updated it and wrote up some instructions here https://github.com/burukuru/jenkins-update-ec2-ami |
This is a proposed fix for JENKINS-28268
Our Use Case
At FreshBooks, we have multiple Packer jobs that build new Jenkins build workers as and when the underlying repos are updated. The problem with this approach (currently) is that after this is done, someone needs to go in and manually update the Jenkins configuration to point to the new AMI ID.
Proposed Fix
With this approach, we could trigger a post-build Groovy script to automatically go in and update the relevant AMI ID without us having to do this manually.
Groovy Example
Here is an example Groovy script that demonstrates getting and setting the AMI ID programatically:
Reference
https://issues.jenkins-ci.org/browse/JENKINS-28268
Local Test Results