Skip to content

Instantly share code, notes, and snippets.

@shollingsworth
Created November 13, 2020 21:43
Show Gist options
  • Save shollingsworth/034832d3bed19b8cc87a5ae1ecfc12db to your computer and use it in GitHub Desktop.
Save shollingsworth/034832d3bed19b8cc87a5ae1ecfc12db to your computer and use it in GitHub Desktop.
change the ami id of jenkins ec2-plugin through groovy
import hudson.plugins.ec2.SlaveTemplate
import jenkins.model.Jenkins
Jenkins jenkins = Jenkins.getInstance()
for (i in jenkins.clouds) {
if (i.searchName == 'ec2-agent') {
println i.templates[0].ami
// i.templates[0].ami = 'ami-xxxxxxx'
}
}
jenkins.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment