Unicorn - Sync Configuration

Octopus.Script exported 2015-09-07 by elkaz belongs to ‘Sitecore’ category.

Sync Unicorn items

Parameters

When steps based on the template are included in a project’s deployment process, the parameters below can be set.

Base Url

BaseUrl

e.g. http://mywebsite.com.au/ - This should be where you’d normally manually sync Unicorn

Configuration Name

ConfigName

e.g. Default Configuration

Timeout

Timeout = 10800

The timeout for the Web-Invoke method

Deployment Auth Token

DeploymentAuthToken

The auth token used to authenticate this request. This should be in your web.config appSettings as DeploymentToolAuthToken.

Basic Auth Username

BasicAuthUsername =

Fill this in if the target site is behind basic auth

Basic Auth Password

BasicAuthPassword =

Fill this in if the target site is behind basic auth

Script body

Steps based on this template will execute the following PowerShell script.

$url = "$BaseUrl/unicorn.aspx?verb=Sync&configuration=$ConfigName"
Write-Host "Syncing configuration: $ConfigName"
Write-Host "Attempting to invoke: $url"
$deploymentToolAuthToken = $DeploymentAuthToken
$timeout = $Timeout
$basicAuthUser = $BasicAuthUsername
$basicAuthPass = $BasicAuthPassword
$secpasswd = ConvertTo-SecureString $basicAuthPass -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential($basicAuthUser, $secpasswd)
$result = Invoke-WebRequest -Uri $url -Headers @{ "Authenticate" = $deploymentToolAuthToken } -TimeoutSec $timeout -UseBasicParsing 

Write-Host $result.Content

Provided under the Apache License version 2.0.

Report an issue

To use this template in Octopus Deploy, copy the JSON below and paste it into the Library → Step templates → Import dialog.

{
  "Id": "993b2b9a-05a4-4dbd-b5b7-3dc0358acac8",
  "Name": "Unicorn - Sync Configuration",
  "Description": "Sync Unicorn items",
  "Version": 8,
  "ExportedAt": "2015-09-07T02:20:43.772+00:00",
  "ActionType": "Octopus.Script",
  "Author": "elkaz",
  "Parameters": [
    {
      "Name": "BaseUrl",
      "Label": "Base Url",
      "HelpText": "e.g. http://mywebsite.com.au/ - This should be where you'd normally manually sync Unicorn",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "ConfigName",
      "Label": "Configuration Name",
      "HelpText": "e.g. Default Configuration",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "Timeout",
      "Label": "Timeout",
      "HelpText": "The timeout for the Web-Invoke method",
      "DefaultValue": "10800",
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "DeploymentAuthToken",
      "Label": "Deployment Auth Token",
      "HelpText": "The auth token used to authenticate this request.\nThis should be in your web.config appSettings as DeploymentToolAuthToken.",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "BasicAuthUsername",
      "Label": "Basic Auth Username",
      "HelpText": "Fill this in if the target site is behind basic auth",
      "DefaultValue": "",
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "BasicAuthPassword",
      "Label": "Basic Auth Password",
      "HelpText": "Fill this in if the target site is behind basic auth",
      "DefaultValue": "",
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    }
  ],
  "Properties": {
    "Octopus.Action.Script.ScriptBody": "$url = \"$BaseUrl/unicorn.aspx?verb=Sync&configuration=$ConfigName\"\nWrite-Host \"Syncing configuration: $ConfigName\"\nWrite-Host \"Attempting to invoke: $url\"\n$deploymentToolAuthToken = $DeploymentAuthToken\n$timeout = $Timeout\n$basicAuthUser = $BasicAuthUsername\n$basicAuthPass = $BasicAuthPassword\n$secpasswd = ConvertTo-SecureString $basicAuthPass -AsPlainText -Force\n$credential = New-Object System.Management.Automation.PSCredential($basicAuthUser, $secpasswd)\n$result = Invoke-WebRequest -Uri $url -Headers @{ \"Authenticate\" = $deploymentToolAuthToken } -TimeoutSec $timeout -UseBasicParsing \n\nWrite-Host $result.Content",
    "Octopus.Action.Script.Syntax": "PowerShell"
  },
  "Category": "Sitecore",
  "HistoryUrl": "https://github.com/OctopusDeploy/Library/commits/master/step-templates//opt/buildagent/work/75443764cd38076d/step-templates/unicorn-sync-configuration.json",
  "Website": "/step-templates/993b2b9a-05a4-4dbd-b5b7-3dc0358acac8",
  "Logo": "iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADNQTFRF////5DAm5j00+MvJ/fLx62Rc7n548ZeS+tjW/OXk6VdP9bGt50pB7HFq97678IuF86SgPP2jTgAAB6BJREFUeNrsXdmuqzAMLNk3CP//tQfaAl3ikFKbclDm4epKRypMYju2kwyXS0VFRUVFRUVFRUVFRUVFRUVFRcUJIXintZIzlNYdF/+LA++VbABI1fP/QUKDHB7Y6GOTEb5lTSFY649qZ75tPkTrj8fCKtZsAFP2UDQ62WyG7I5jU6H5CsGfgsZBqHDXoMD9Nh7btkFD+0O316xBBNM/omFcgwxnfjIdDQH2nxQrGxLInT2Fs4YIjP97s9rfvIRqSKF2SouFa4jhdmFiyXkMTHZweVPu5kHGoUzn5lrAc97rtngMmDkKj6GYTdqH8SocgUkRD6byJYbp3a+ZlPBQJYWS1eGXTMTq04MuDjh8LTcI4mdx98P6yKofReEWvcxbqWdaGh5xJbPYNH75CjOS1OZEWWufCyB+54DFeqKKAD90ZR3924xC7+jwOQdRlOUNspt0xHacyURRG5GCUVd0AgzEDNO41A7eqOgsdzHhXaIKyASvig/7REeISSBvNWBHeUXbjgA9HX+1akn9Pe6XP0DLLspiYvfsP1lg9i2h4UqaFiZZCLZ7rFPrkcWSeQhFi1aM0cPReAkUsihKHh6agYmhMYB+t8bANdsa3zdtXP2XPx92SEkfC8UWemYgCSLoEWvZxuugh3KK2Iu8pIv47AwSPQIL8sT6WrWFlx4QR3d3T7fOwr0HDkzJNxlRSz8h73v1DpiSFt2yENfCZH/OA1Oy3bY64pAlIlRIedyYr2izd8/g+iCgmnQgzRbhVllI/3HzmmhpXT3TvOTpjMuiBl+87ATulrVpa/CYLsLoq6hrgIqIxuDIN18U3A5I2Zb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cp7yP6TApt1cIypt5Pq64rSD9izboYIptIgWBZh/n/hB8GHRw+Mk65ENQla3u+YRet+/D3NqOJXho4otpsADAA5PBvkr1MyU3MpUSevIbj6GIyZCNmwJFU8kTeiisy/DAa9PC53OfmTTSiy7LJURrVNLbMiofiFsZGUmZYJ6OhjPVjVE3ScZFI7xMjkbuEZgbABmphFEr4eUlRn1ly3WU80uzwf87YQFF4JhTSkC+gpoTrxjyuXezcK32fFlWDNct4Gmje+S0K5FvCmb1doZ8C3wTJvPSSe0w4F1mwrGvoOaVnAIXsdmCcTqyIoP4ik4rGmFRmA1ammOq2eVEuyjUwvzK2PqPJYxHPewVYSoSQeO4utJ9RGWkIVaEdklkqVaFwm5Uygws6AIaVEJhJZKZsrvYuDYtN9VAG9fSGToBTRHKxtr08Ly4eF0YCtTyA6EQaJncpOvtWILE10TFjcv7c/m7c8D6lMmYHPprUWevJYkf/72Pb9FHJJqDSGdOa3rUfBECNdz/SzHT78B2kPk+i0zueYSLzyMlfTmNuPflPHLr5xHAv5zmkwSX83wk4nKaz3ZczvMhlctpPm1zrSzO8bEhDCrhOB8YO8kHuW5bbaf4RNqlsAx/DVQH/GjdLS0+x2cEP6jJj/5hx5nMGT61udjZCT5+WlFRUVFRUVFRUVFRUVFRUVFRUVGGPwEGAF3QUYekQeUKAAAAAElFTkSuQmCC",
  "$Meta": {
    "Type": "ActionTemplate"
  }
}

History

Page updated on Monday, September 7, 2015