Closed gitlabbin closed 5 years ago
Good point. In ServiceNow its by design that, during a deployment, some actions might need to be done manually, but manual actions actually are not what we want in a CICD pipeline :-/
So all deployment related objects must be part of the updateset.
The 'Create Application File from Record' OOB feature can help to attach such records to an updateset. It actually creates an XML dump of the record into a sys_metadata_link record.
Alternatively the below script can be used to manually add any kind of files to an update-set.
function addToUpdateSet(usSysId, className, sysId) {
// check if us exists
var us = new GlideRecord('sys_update_set');
if (us.get(usSysId)) {
// 'Make This My Current Set'
new GlideUpdateSet().set(usSysId);
} else {
throw Error('Updateset not found' + usSysId);
}
var gr = new GlideRecord(className);
if (gr.get(sysId)) {
// add record to update-set
new GlideUpdateManager2().saveRecord(gr);
gs.info("done");
} else {
gs.info("record not found: " + className + ':' + sysId);
}
}
There is also the option to create an UI action with the above script to allwo to collect records to US from the UI.
If a deployment requires some script to be executed post go-live, there is also an option to create a scheduler (sysauto_script) with all scripts. After a successful run, the scheduler can disabling (or even delete) itself.
Thanks @bmoers , will try it. close it now.
Update set with 'group' data records committed successfully, but the data record can't be see from system groups:
Source and Target servers:
two free instances ServiceNow (glide-london-06-27-2018__patch1-08-15-2018_08-22-2018_1559)
Steps to produce:
Add UI Action into source instance https://community.servicenow.com/sys_attachment.do?sys_id=708c1882dbdc17041dcaf3231f9619de
Create a new group record "mytest"
Click 'Force to updateset' button, the record will insert into current Updateset
Use SN-CICD to deploy this updateset
Check on target server, the updateset is committed
, the updateset having the xml
piece of group record "mytest"
Check 'System security - Groups' on target server, no any new records created
Any thing wrong with the target server committed the updateset ?
More tests: using the same updateset generated from above steps On target server:
Any difference between SN-CICD commit
vs. SNOW commit update set
button?
sn-cicd-integration:
Turn out this code working:
var commitResult = new UpdateSetCommitAjax((function () {
var params = {
sysparm_type: 'commitRemoteUpdateSet',
sysparm_remote_updateset_sys_id: payload.remoteUpdateSetSysId
};
return {
getParameter: function (paramName) {
return params[paramName];
}
};
})(), new GlideXMLDocument(), '').process();
var progress_id = commitResult.split(',')[0];
The following one can't handle the data record of the update set
var worker = new SNC.HierarchyUpdateSetScriptable();
var progress_id = worker.commitHierarchy(payload.remoteUpdateSetSysId);
@bmoers , Can you please confirm my finding?
Seems the HierarchyUpdateSetCommitAjax does not work for forced records. @gitlabbin can you check if forced records in hierarchical update-sets get installed (with 'new SNC.HierarchyUpdateSetScriptable()' ..)
The 'commitRemoteUpdateSet' only works for non-hierarchical update-sets. So it requires a check first to run either or.
Let me check.
I was not able to reproduce the issue. @gitlabbin can you please share the update-set you tested?
Attached the one I have used. Test - No Parent- sys_remote_update_set_459ab967db42230051cefbef29961993.zip
The simple updateset just with a group
record:
please look at here https://gist.github.com/gitlabbin/0409792d54f921700688154532ffa9a5
Deployed a fix in https://github.com/bmoers/sn-cicd-integration/commit/7d3d70c1cdb66125d841fbedb9e440d32c62b64d
Please take latest update-set from here https://github.com/bmoers/sn-cicd-integration/blob/master/update_set/CICD%20Integration.xml
Great, close this. 👍
When we migrate updateset from dev instance to test instance, some updateset requires additional data or configuration changes.
How will SN-CICD handle it? or any good practice for that case?