GithubHelp home page GithubHelp logo

Comments (10)

bmoers avatar bmoers commented on August 21, 2024

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.

from sn-cicd.

gitlabbin avatar gitlabbin commented on August 21, 2024

Thanks @bmoers , will try it. close it now.

from sn-cicd.

gitlabbin avatar gitlabbin commented on August 21, 2024

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 ?

from sn-cicd.

gitlabbin avatar gitlabbin commented on August 21, 2024

More tests: using the same updateset generated from above steps
On target server:

  • use SNOW 'retrieve updateset' button, find the updateset and then click 'commit update set' button
  • updateset will be 'committed', and 'System security - Groups' on target server, having the right records created

Any difference between SN-CICD commit vs. SNOW commit update set button?

from sn-cicd.

gitlabbin avatar gitlabbin commented on August 21, 2024

sn-cicd-integration:

https://github.com/bmoers/sn-cicd-integration/blob/276769a0e177ee508460d5b41e7a3c66d48b6e1f/script_include/CiCdDeploy.js#L599-L616

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?

from sn-cicd.

bmoers avatar bmoers commented on August 21, 2024

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.

from sn-cicd.

bmoers avatar bmoers commented on August 21, 2024

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

from sn-cicd.

gitlabbin avatar gitlabbin commented on August 21, 2024

The simple updateset just with a group record:
please look at here https://gist.github.com/gitlabbin/0409792d54f921700688154532ffa9a5

from sn-cicd.

bmoers avatar bmoers commented on August 21, 2024

Deployed a fix in bmoers/sn-cicd-integration@7d3d70c
Please take latest update-set from here https://github.com/bmoers/sn-cicd-integration/blob/master/update_set/CICD%20Integration.xml

from sn-cicd.

gitlabbin avatar gitlabbin commented on August 21, 2024

Great, close this. 👍

from sn-cicd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.