Benjamin Nuttin
Giga Expert

Just uploaded to Share a quick app I made to automatically upload local update sets to your GitHub repository. That way if you lose access to your dev instance, you haven't lost all your code and configs. Of course this is even more useful if you're really diligent about organizing your update sets, but that's another topic altogether...

The app is fired by a scheduled job, and then goes through each update set and offloads it (the same way you do when you click the "Export to XML" link) to an XML packet. That packet is then uploaded to GitHub via REST. The file name of the upload is the instance name plus the sys_id of the update set. The description of the file is the description of your update set in ServiceNow.

The app keeps track of when it last sent an update set, so it only sends update sets that were updated since last time, and each upload shows up as a different commit of the same file. The app can upload to a public or a private repo as well.

Link: https://share.servicenow.com/app.do#/detailV2/4911c924db749f001afe13141b961970/overview

Please let me know if you run into any issues or have any feedback!

 

find_real_file.pngfind_real_file.png

Comments
ryanlitwiller
Giga Guru

I'm not getting any customer updates in the temp retrieved update set record it makes in the UpdateSetUtil. I've pasted a snippet of the code which doesn't seem to actually create copies of the customer updates and I'm not sure how it would as the only fields it setting is remote_update_set.

I've also been working to add gitlab, if you want to create a github repo I'd be happy to contribute to this.

// Now iterate through all the customer updates from the original update set and create copies assigned to the new update set
		var custUpdate = new GlideRecord('sys_update_xml');
		custUpdate.addQuery('update_set', updateSet.sys_id);
		custUpdate.query();
		while(custUpdate.next()) {
			custUpdate.remote_update_set = sysid;
			custUpdate.update_set = '';
			custUpdate.insert();
		}
Benjamin Nuttin
Giga Expert

Sorry you're having issues. I will have to do some testing on my end.

 

The custUpdate object does not get initialized, so it inherits all the field values from the original query. Then we just replace the remote_update_set and update_set values, and insert as a separate record (similar to Insert vs. Save).

ryanlitwiller
Giga Guru

Ah! Good example of the when and why we would or wouldn't use initialize.

I think I found the issue:

custUpdate.remote_update_set = sysid;

Is associating the copied customer updates back to the original update set and not the newly created retrieved update set. Instead I associated the "returnid" variable for the newly created update set.

var returnid = retrievedUpdateSet.insert();
// Now iterate through all the customer updates from the original update set and create copies assigned to the new update set
var custUpdate = new GlideRecord('sys_update_xml');
custUpdate.addQuery('update_set', updateSet.sys_id);
custUpdate.query();
while(custUpdate.next()) {
	custUpdate.remote_update_set = returnid;
	custUpdate.update_set = '';
	custUpdate.insert();
}		
		
Benjamin Nuttin
Giga Expert

I think you're right - though I don't know why it worked for me before, then... I will continue testing. Thanks!!

Jennifer Schoe1
Tera Expert

I am getting a 404 error on your link.  Can you please check and let me know where we can find it?

DScroggins
Kilo Sage
You can find the app here: https://developer.servicenow.com/connect.do#!/share/contents/3449768_git_my_stuff?v=1.1&t=PRODUCT_DETAILS
Community Alums
Not applicable

This is helpful.

Version history
Last update:
‎03-08-2018 03:20 PM
Updated by: