1

We are moving code repo from Github to Gitlab. It was just simple project without any much customization. So we were using github connecttion in xm cloud i.e out of the box setup provided in xm cloud deploy app.

Since xm cloud allows only a connection form Github, is there a way if I can do the deployment from gitlab.

I know we can customize it with help of Sitecore cli but could not find an example to set it up with gitlab without a complex ci/cd pipeline.

Does anybody already have experience with deployment with gitlab in xmcloud or is there a document online which I can refer?

1 Answer 1

1

Firstly, as of the current information available, Sitecore XM Cloud officially supports GitHub and Azure DevOps source control providers.

If you are using a GitLab source control and wish to deploy code to Sitecore XM Cloud, you'll need to leverage Sitecore CLI and set up pipelines in GitLab.

Here's a general outline of the process:

  1. Build Pipeline: Set up a build pipeline in GitLab that builds your solution and creates the necessary artifacts (e.g., a ZIP file).

  2. Release Pipeline: In the release pipeline, use inline PowerShell scripting to handle the deployment to Sitecore XM Cloud. Below is an example script:

    cd "_PROJECT - XM Cloud-.NET Desktop-CI/drop/"
    
    Get-ChildItem -Path ".\*.zip" | ForEach-Object {
        Write-Host "Zip found and extracting ... " + $_.Name
        Expand-Archive -Path $_.Name -Force
    
        cd $_.BaseName
        cd s
        Write-Host "Run release script ... "
    
        $ErrorActionPreference = "Stop";
    
        if (!-not $(Get-PackageSource -Name Sitecore -ProviderName NuGet -ErrorAction Ignore)) {
            Write-Host "Adding Sitecore NuGet Source" -ForegroundColor Green
            dotnet nuget add source -n Sitecore https://sitecore.myget.org/F/sc-packages/api/v3/index.json
        }
    
        Write-Host "Installing Sitecore dotnet CLI" -ForegroundColor Green
        dotnet tool update Sitecore.CLI 
    
        Write-Host "Logging into XM Cloud" -ForegroundColor Green
        dotnet sitecore cloud login --client-credentials --client-id $env:ClientId --client-secret $env:ClientSecret
    
        Write-Host "Creating the deployment" -ForegroundColor Green
        dotnet sitecore cloud deployment create --environment-id $env:EnvironmentId --upload
    }
    
  3. Environment Variables: Define the necessary environment variables in your GitLab pipeline, which will be referenced by the PowerShell script. These variables may include ClientId, ClientSecret, EnvironmentId, etc.


You can refer to the below resources for detailed information: https://doc.sitecore.com/xmc/en/developers/xm-cloud/the-cloud-deployment-command.html

https://www.getfishtank.com/blog/deploy-sitecore-xm-cloud-from-devops-release-pipeline-using-the-cli

2
  • Thanks for your valuable inputs. Will work on it. Jan 24 at 13:17
  • 2
    While you can build before the deploy to make sure there are no errors, it is not required. Its important to remember that the CLI deployment requires the original source code, not a build artifact. XM Cloud deploy will build your code and deploy it.
    – Richard Seal
    Jan 24 at 13:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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