Trigger Creative Exchange from your CI server

Current version: 10.1

To quickly change the styling of your SXA sites, you can trigger Creative Exchange from your Continuous Integration (CI) server. Continuous integration enables you to integrate code changes routinely into the main branch of a repository, and to test the changes, as early and often as possible.

Note

Before you start working on automating your Creative Exchange deployment, you must understand how to use the Sitecore PowerShell Extensions Web API.

Trigger export and import

To trigger export and import using a simple web request:

  • Create endpoints for the Creative Exchange import and export. For examples, go to:

    RequestResponse
    /sitecore/system/Modules/PowerShell/Script Library/SXA/SXA - Creative Exchange/Web API/ce-export
    /sitecore/system/Modules/PowerShell/Script Library/SXA/SXA - Creative Exchange/Web API/ce-import
    Create endpoints
Note

Do not save your web request items under any of the SXA roots as they might be overwritten in the next release.

  1. In the import section, import the cmdlets:

    Get-CreativeExchangeExportResponse

    Get-CreativeExchangeImportResponse

  2. Specify the path. For example:

    $item = Get-Item -Path "/sitecore/content/Tenant/Site/Home"

  3. Specify the cmdlet and its parameters. For example:

    $exportArgs = Get-CreativeExchangeExportResponse -CurrentItem $item -DeviceId "{FE5D7FDF-89C0-4D99-9AA3-B5FBD009C9F3}"

    You can modify the parameters to change the import/export options.

  4. When the export/import is complete, you get the $exportArgs/$importArgs object as a result:

    • $exportArgs (Sitecore.XA.Feature.CreativeExchange.Pipelines.Export.Export.ExportArgs)

    • $importArgs

    • (Sitecore.XA.Feature.CreativeExchange.Pipelines.Export.Export.ImportArgs)

  5. Use the $responseObject object to retrieve the content for the parameters.

    You can use it to fetch necessary information and return it as a Web API response. In the following example, we have built a dynamic object and serialized the specified object to JSON format:

    RequestResponse
    Import-Function Get-CreativeExchangeExportResponse
    $item = Get-Item -Path "/sitecore/content/Tenant/Site/Home"
    $exportArgs = Get-CreativeExchangeExportResponse -CurrentItem $item -DeviceId "{FE5D7FDF-89C0-4D99-9AA3-B5FBD009C9F3}"
    $responseObject = @{
        "Messages" = $exportArgs.Messages;
        "Result"   = $exportArgs.CreativeExchangeExportStorage.GetResult()
    }
    Set-HostProperty -HostWidth 9999
    [Newtonsoft.Json.JsonConvert]::SerializeObject($responseObject)

Change export options using the Get-CreativeExchangeExportResponse cmdlet

The following table describes the available Get-CreativeExchangeExportResponse cmdlet parameters.

To change the export options:

  • Modify the parameters of the Get-CreativeExchangeExportResponse cmdlet.

    Type

    Name

    Mandatory

    Default

    [Item]

    CurrentItem

    true

    [Sitecore.XA.Feature.CreativeExchange.Storage.CreativeExchangeStorageDefinition]

    StorageDefinition

    false

    "Folder on server"

    [Sitecore.XA.Feature.CreativeExchange.Enums.MarkupMode]

    MarkupMode

    false

    [Sitecore.XA.Feature.CreativeExchange.Enums.MarkupMode]::AgencyDrop

    [Sitecore.XA.Feature.CreativeExchange.Enums.ExportScope]

    ExportScope

    false

    [Sitecore.XA.Feature.CreativeExchange.Enums.ExportScope]::Site

    [Sitecore.XA.Feature.CreativeExchange.Enums.BucketExportMode]

    BucketExportMode

    false

    [Sitecore.XA.Feature.CreativeExchange.Enums.BucketExportMode]::OneOfTemplate

    [string]

    Language

    false

    "en"

    [int]

    FileSizeLimit

    false

    0

    [Sitecore.Data.ID]

    DeviceId

    false

    "{FE5D7FDF-89C0-4D99-9AA3-B5FBD009C9F3}"

    [string]

    UserName

    false

    "sitecore\\admin"

Change import options using the Get-CreativeExchangeImportResponse cmdlet

The following table describes the available Get-CreativeExchangeImportResponse cmdlet parameters.

To change the import options:

  • Modify the parameters of the Get-CreativeExchangeImportResponse cmdlet.

    Type

    Name

    Mandatory

    Default

    [Item]

    CurrentItem

    true

    [Sitecore.XA.Feature.CreativeExchange.Storage.CreativeExchangeStorageDefinition]

    StorageDefinition

    false

    "Folder on server"

    [int]

    FileSizeLimit

    false

    0

    [Sitecore.Data.ID]

    DeviceId

    false

    "{FE5D7FDF-89C0-4D99-9AA3-B5FBD009C9F3}"

Do you have some feedback for us?

If you have suggestions for improving this article,