Reputation: 2805
I'm hoping to create a Jenkins 2 pipeline job that will backup an image of the master node in aws, and then update any Jenkins plugins that need updating. The goal is to run this about once every 3-4 days when there's downtime to ensure everything is up to date, without needing to manually go through all the steps of logging into aws, making the backup, logging into jenkins and updating the plugins, etc.
After about an hour of research I'm no closer to finding even a partial solution for either of the two steps, so I'm reaching out to the community.
I'd be shocked if neither of these can be done, but as a noob to Jenkins I'm struggling.
As an aside, I have seen/researched thinBackup but it doesn't seem to have the options I'm looking for. Please correct me if I'm wrong!
Upvotes: 1
Views: 697
Reputation: 498
You can use the Scriptler Plugin to execute the following groovy script on Jenkins master from a Jenkins job.
import jenkins.model.Jenkins
def uc = Jenkins.instance.updateCenter
uc.updateAllSites()
uc.updates.each {
print('Updating ' + it.title + ' Plugin from ' + it.installed.version + ' to ' + it.version + ' ...\n')
it.deploy().get()
}
You can also schedule a save restart to activate the new plugin versions after you deployed them.
Jenkins.instance.safeRestart()
Upvotes: 2
Reputation: 2691
Upvotes: 0