Plugins update with Script

mchandr
Tera Contributor

Is there any way the plugins can be updated using background scripts, other than directly updating from UI or downloading it from store? 

9 REPLIES 9

Still working on that Frank 😉


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

Anubhav24
Mega Sage
Mega Sage

HI @Jeffrey Barton @HDLawrence ,

 

I found this script from @Maik Skoddow for installing plugins he shared on LinkedIn , I am yet to use it but kindly let us know your results as well.

https://github.com/mskoddow/sn-scripts/blob/master/install_plugins_and_applications.js

 

Please mark helpful/correct if my response helped you.

@Anubhav24 

That's a really neat script. Great find. And thanks to @Maik Skoddow for publishing that. Works great.

I'm looking for a script that can update plugins and applications and that one filters those out. 

Will continue searching and update if I find/write anything useful.

HDLawrence
Tera Contributor

Dug through the script includes that @Maik Skoddow referenced. There are functions available for updating plugins as well. Here's a short little script that runs through and updates all available plugins. I have it referencing a specific sys_properties record where I store a list of plugin ID's that we don't want automatically updated in this script. 

Hope this helps!

//First, query a list of all plugins that can be updated.
var availPlugins = new GlideRecord('sys_store_app');
availPlugins.addEncodedQuery('hide_on_ui=false^update_available=True');
availPlugins.query();

gs.log('Starting plugin update cycle','Plugin Update Process');


//Second, define variables, pull skip list from properties
var skipProperty = new GlideRecord('sys_properties');
skipProperty.get('06fe09951b528e10c8e062007e4bcb3b');

var skipList = skipProperty.value;
var report = 'Plugin update report: \n';
var worker = new sn_appclient.AppUpgrader();


//Third, loop through all plugins to update them while skipping plugins listed on the skip list
while(availPlugins.next()){
	if(skipList.indexOf(availPlugins.source) == -1){
		report = report.concat('Updated ' + availPlugins.source) + ' from ' + availPlugins.version + ' to ' + availPlugins.latest_version + '\n';
		worker.upgrade(availPlugins.sys_id.toString(), availPlugins.latest_version, false);
	} else {
		report = report.concat('Skipped ' + availPlugins.source) + '\n';
	}
}


//Fourth, send report to sys_log
gs.log(report,'Plugin Update Process');