10

I have used TDS for most of my packages for deployment or creating modules for co-workers and friends. TDS is great at creating update packages. Is there a process to take all Unicorn items and convert them into a Sitecore package?

  • Have you considered using Sitecore PowerShell Extensions to simply zip the files up and then transfer to the other instance? Do you need them to be in the .item or .yaml format? – Michael West Oct 3 '16 at 22:43
9

As far as I know, I can say no there isn't at this point. Please correct me if I am wrong someone. However you can do the following to deploy sitecore items.

Source: https://github.com/kamsar/Unicorn

Automated Deployment

With Unicorn you've got two options for automated deployment of item changes, for example from a Continuous Integration server or production deploy scripts.

Use Transparent Sync

When using Transparent Sync, the items on disk magically appear in Sitecore without syncing. So one automated deployment option is to simply use Transparent Sync and copy your updated serialized items to the deployment target alongside your code. This is advantageous because it's simple to set up and requires no direct intervention with the deployed server after deployment (e.g. a HTTP call).

Use the Automated Tool API

Unicorn has an automated tool API whereby you can invoke actions in the Unicorn control panel from a script, such as invoking a sync after a code deployment.

NOTE: Automated Tool API is completely overhauled in Unicorn 3.1, and these instructions are for 3.1 only

Tools are authenticated using a shared secret between the tool and the Sitecore server running Unicorn, which is relayed via CHAP+HMAC-SHA512. The practical upshot of this is that the shared secret never travels over the wire, the authentication key is unique every time, and replay attacks are not possible. You should still use the tool API over a TLS connection if possible.

Calls to the control panel from an automated tool behave a little differently from interactive control panel sessions. Specifically:

  • Automated calls are not streaming (nothing is written to the response until everything is complete)
  • Automated calls return HTTP 500 if an error occurs (interactive calls that fail return HTTP 200, because the HTTP headers have been sent long before the error occurs). In the example PS script above, this will throw a PowerShell exception.
  • The output is text formatted, instead of HTML formatted, so it is much easier to read in logs.

Ok, ok. Shut up about crypto and tell me how to set it up.

  1. Generate a very long random shared secret key, preferably using a password generator. There are no limits on character count, character types, etc but it must be > 30 characters.
  2. Install the shared secret into the Unicorn.UI.config file - or a patch thereof, under the authenticationProvider/SharedSecret node. There are comments to help.
  3. To call the tool API from a script, a PowerShell module is provided. Acquire the module and its supporting files from the doc\PowerShell Remote Scripting folder of the Unicorn git repository.
  4. Review the sample.ps1 file and adapt it to your needs, including putting the shared secret into it and setting the URL as needed. Don't worry the guts of sample.ps1 are two simple lines of code :)

NOTE: When deploying to a Content Editing or Content Delivery server, the Unicorn configuration should be trimmed down from development. Each config file in App_Config/Include/Unicorn has comments at the top designating what environment(s) it should live on. If you opt to use Transparent Sync as a deployment mechanism, make sure you do not disable the data provider config file.

Darren Guy has written a practical dissertation on his experiences setting up Unicorn 3 with TeamCity and Octopus Deploy that goes all the way from install to automated deployment. A recommended read if you're wanting to use a similar setup.

Andrew Lansdowne has also written a post (for version 1, so some of it is outdated but the concepts still apply) about setting up Unicorn with TeamCity and WebDeploy that may be useful when setting up automated deployments.

7

For anyone coming to this question far in the future, you can explicitly combine your Unicorn configuration into a package with SPE

See https://kamsar.net/index.php/2017/02/Unicorn-4-Preview-Part-2-5-Generating-Packages-with-SPE/

# Create a new Sitecore Package (SPE cmdlet)
$pkg = New-Package
# Get the Unicorn Configuration(s) we want to package
$configs = Get-UnicornConfiguration "Foundation.*" 
# Pipe the configs into New-UnicornItemSource 
# to process them and add them to the package project
# (without -Project, this would emit the source object(s) 
#   which can be manually added with $pkg.Sources.Add())
$configs | New-UnicornItemSource -Project $pkg
# Export the package to a zip file on disk
Export-Package -Project $pkg -Path "C:\foo.zip"
  • 1
    So to be clear, I can take all the items tracked by a Unicorn configuration and send it to a standard item package with .item files. – Michael West Dec 14 '17 at 3:01
6

There is Sitecore Courier which generates a package from your serialized items. It also supports Unicorn files. You can then use Sitecore Ship to install the package on a remote server.

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.