Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sanele Ngidi 15 posts 95 karma points
    Dec 01, 2023 @ 09:46
    Sanele Ngidi
    0

    Extending uSync.Complete Publisher to get Published Configs

    Hi,

    I have a requirement to automate exporting uSync configuration and create a DevOps PR with configs during the uSync. Export process. I need to intercept the process where the configs are ready to be imported on the target server to get those configs to use in PR creation.

    I need some assistance on how can I go about getting the configs during this process?

  • Kevin Jump 2343 posts 14890 karma points MVP 8x c-trib
    Dec 01, 2023 @ 11:01
    Kevin Jump
    0

    Hi,

    there are a number of ways you can approach this - depends on what information you want how you want to capture it etc..

    i. you could use the uSync command line to automate the export and import of things to disk (not necessarily the uSync/v9 folder).

    https://github.com/Jumoo/uSync.CommandLine

    ii. you could intercept things with notifications.

    uSync will fire several notifications as things are imported/exported. you could use these to keep track of things.

    for example - uSyncImportingItemNotification (before an item is imported) - uSyncImportedItemNotification (after an item has been imported) - uSyncExportedItemNotification (after export)

    • uSyncImportStartingNotification (before an import process starts)
    • uSyncExportCompletedNotification (at the end of the whole export)

    full list in the repo : https://github.com/KevinJump/uSync/tree/v12/main/uSync.BackOffice/Notifications/uSyncNotifications

    you might find uSyncImportCompletedNotifciation the place where you can see allk the changes that have just happened or uSyncReportCompleted to tell you the changes uSync thinks its about to make.

    iii. Publisher also fires some notifications - but these are more about plumbing in to the request processes.

    • uSyncPublisherActionCompletedNotification -fires at the end of every action (there can be a lot of actions per publish, but you can listen for the name of an action then do things when it completes).

    • uSyncPublisherCompletedNotification - fires at the very end of a publish


    you could do other stuff with source control ,and snapshots too, but if you want it automated that would prob require even more code outside of what uSync is doing.

  • Sanele Ngidi 15 posts 95 karma points
    Dec 07, 2023 @ 09:14
    Sanele Ngidi
    0

    Hi Kevin,

    Thank you so much for your response and it gave me a very good start.

    For my requirement, a notification uSyncPublisherCompletedNotification is what I need, one thing I'm battling with is the notification only gives a PublisherActionRequest which has a collection of SyncItem. A SyncItem does not have details of the item that I can serialize or a serialized string that I can take and push to source control.

    If there's anything you can advise I can do to achieve this, will be highly appreciated.

    Just as side note, I also tested my objective using uSyncImportCompletedNotifciation which has a collection of uSyncAction that has property FileName full path to *.config file that I read to get the content and pushed it to source control. I would like to archive the same thing using uSyncPublisherCompletedNotification

    Your assistance is highly appreciated.

  • Kevin Jump 2343 posts 14890 karma points MVP 8x c-trib
    Dec 08, 2023 @ 11:27
    Kevin Jump
    100

    Hi,

    Yeah, - i think the way the events fire means you can't get the actions from the publisjed one (well you can, but you would have to listen for all action events and build the list manually).

    So you might have to combine both events. so the uSyncImportCompletedNotification will fire, and then uSyncPublisherCompletedNotification will fire,

    thinking about it (e.g theoretically, i haven't tested this) - i would capture the list of actions from the uSyncImportCompletedNotification in a cached or static object, and then when the PublishedNotification fired, i would use those cached values. to do any work i needed.

    Like i say, that's a theory.

    but...

    if you truly want everything that is on the site to make it into source control, you might be better using the uSyncExportedItemNotification events, because then you will capture all change events, even if they are not via uSync publisher (e.g. if a dev logs on to the machine and makes a change, the uSyncExported event will fire)

Please Sign in or register to post replies

Write your reply to:

Draft