7

So we've been successfully using Unicorn in a development only environment for the past few months. We have Content and Media Library items synced and always deployed which obviously shouldn't be the case when we go to a production environment, but I'm unsure of the best way to transition. Since we will have content in the Content and Media Library that we might need to "Deploy Once" and the rest we wouldn't want to ever deploy (we will work on deleting those items).

How can we configure this correctly. Is there a way to specify the serialization as deploy once in the serialization patch. Example, we have a patch that looks like this:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <unicorn>
      <configurations>
        <configuration name="Feature.Navigation" description="Feature Navigation" dependencies="Foundation.Serialization" patch:after="configuration[@name='Foundation.Serialization']">
          <targetDataStore physicalRootPath="$(sourceFolder)\feature\navigation\Serialization" type="Rainbow.Storage.SerializationFileSystemDataStore, Rainbow" useDataCache="false" singleInstance="true" />
          <predicate type="Unicorn.Predicates.SerializationPresetPredicate, Unicorn" singleInstance="true">>
            <include name="Feature.Navigation.Templates" database="master" path="/sitecore/templates/Feature/Navigation" />
            <include name="Feature.Navigation.Renderings" database="master" path="/sitecore/layout/Renderings/Feature/Navigation" />
            <include name="Feature.Navigation.Media" database="master" path="/sitecore/media library/Feature/Navigation" />
            <include name="Feature.Navigation.Dictionary" database="master" path="/sitecore/content/global/dictionary/navigation" />
          </predicate>
        </configuration>
      </configurations>
    </unicorn>
  </sitecore>
</configuration>

So in that example above, the dictionary items and the media library are both areas in the content portion of Sitecore and ideally, we would only want to deploy once the items in those areas. Is there a way to configure Unicorn to deploy once for those folders.

9

Yep. Using the NewItemsOnly evaluator.

Add this under your <configuration> element.

<evaluator type="Unicorn.Evaluators.NewItemOnlyEvaluator, Unicorn" singleInstance="true"/>

You can find an example of this in your Unicorn folder. Unicorn.Configs.NewItemsOnly.example


Be aware.

Be aware of a few caveats though. I've been using this one myself in a scenario not too different from what you describe. And for most content, we had various example images and content set up - like menu elements for the Footer and so on.

What happened was, that the client wanted to get rid of some of these example navigational elements and therefore deleted them. Then complained they kept coming back on each deploy. Which is obvious when you think about it - just keep this in mind when layout out your configurations :-)

  • It would be nice if you could specifically say what items you wanted to be deploy once vs. not. With that you would have to either define multiple configurations to achieve that result or go with an all or nothing approach. I absolutely agree with what you mention. It's tough. Because with a new website launch you would want a sample set of items, but at some point you'd need to remove those from source control so you don't run into the scenario you describe. – Dylan Young Oct 30 '17 at 15:55
  • Yes. Well it comes down to how Unicorn (Rainbow) operates, as a data provider. So it cannot support a "pick and choose" type selection of items to include. I solved it by using multiple configurations - like one that included template, rendering definitions and so on - system level stuff. And then a content configuration for NewItemsOnly. On our local environments, we share the content stuff fully in source control. On QA and onwards, we map in the NewItemsOnly evaluator. – Mark Cassidy Oct 30 '17 at 15:57
  • 1
    That sounds like the approach I will need to take with this as well. Thanks for your assistance :-) – Dylan Young Oct 30 '17 at 15:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.