CI/CD YAML Pipelines for Optimizely CMS 12

CI/CD YAML Pipelines for Optimizely CMS 12

Multi-stage Azure YAML pipelines to setup CI/CD for ASP.NET 5+ and Optimizely CMS 12 projects using Deployment API.

I had previously successfully used multi-stage YAML pipelines for CMS 11 projects. These YAML pipelines are great as they can be easily ported across projects for quick and consistent setup of CI/CD workflows.

Build and Package for .NET 5+

In the new world of ASP.NET Core and CMS 12, I had to tweak the build and package processes to maintain the CI/CD functionality.

The .NET Core task can be used to easily restore, build, test, package and publish a .NET Core project. The following code snippets outline the key steps:

Restore dependencies

- task: DotNetCoreCLI@2
  displayName: 'NuGet Restore'
  inputs:
    command: 'restore'
    projects: '$(projects)'
    feedsToUse: 'config'
    nugetConfigPath: 'src/NuGet.config'

Build

- task: DotNetCoreCLI@2
  displayName: 'Build'
  inputs:
    command: 'build'
    projects: '$(projects)'
    arguments: '--configuration $(buildConfiguration) --framework $(targetFramework)'

Test

Run any unit tests

- task: DotNetCoreCLI@2
  displayName: 'Test'
  inputs:
    command: 'test'
    projects: '**/*Tests/*.csproj'
    arguments: '--configuration $(buildConfiguration)'

Package and Publish

The files need to be packaged in NUPKG file format

- task: DotNetCoreCLI@2
  displayName: 'Publish output'
  inputs:
    command: 'publish'
    publishWebProjects: true
    arguments: '--configuration $(BuildConfiguration) --framework $(targetFramework) --output $(Build.ArtifactStagingDirectory)\PackageContent\'
    zipAfterPublish: false
    modifyOutputPath: false

- task: ArchiveFiles@2
  displayName: 'Zip'
  inputs:
    rootFolderOrFile: '$(Build.ArtifactStagingDirectory)\PackageContent\'
    includeRootFolder: false
    archiveType: 'zip'
    archiveFile: '$(Build.ArtifactStagingDirectory)/Packages/$(appName).cms.app.$(appVersion).nupkg'
    replaceExistingArchive: true

- task: PublishPipelineArtifact@1
  displayName: 'Publish artifact'
  inputs:
    targetPath: '$(Build.ArtifactStagingDirectory)/Packages'
    artifact: '$(artifactName)'
    publishLocation: 'pipeline'

Deployment

The actual deployment processes that use the Deployment API to upload and deploy the code package to DXP environments remain the same.

Pipelines

The following YAML pipeline files can be found in my GitHub repository,

  • Integration - builds, tests and deploys to the Integration environment.

  • Release - builds, tests and enables staged deploys of release candidates to Preproduction and Production environments.

As these pipelines directly use the EpiCloud Powershell module, you have full control of the scripts to change as per your CI/CD requirements.

Refer to my series on Deployment API and YAML pipelines for more context - Part 1, Part 2, Part 3.

Stay tuned for more updates!