Push Helm v3 Charts to Azure Container Registry

Azure DevOps Pipeline script

steps:
- checkout: self
  clean: true

- template: version.azure-pipelines.yml
  parameters:
    directory: bckeda-rabbitmq

- task: HelmInstaller@0
  displayName: ⤵ Instal Helm CLI
  inputs:
    helmVersion: '3.8.0'
    installKubectl: false

- task: HelmDeploy@0
  displayName: 📦 Pack Helm Chart
  inputs:
    command: 'package'
    chartPath: '$(workingDirectory)'
    chartVersion: '$(Version)'

- pwsh: |
    $env:HELM_EXPERIMENTAL_OCI=1
    $ACR="dwestaticplatformcr015vx.azurecr.io"
    helm registry login $ACR --username ($env:Username) --password ($env:Password)
    $Packages = "{0}/*.tgz" -f $env:BUILD_ARTIFACTSTAGINGDIRECTORY | Get-ChildItem
    $Packages | % {
        helm push $_.FullName oci://$ACR/helm
    }

    if ($LastExitCode -ne 0){
        throw "Something went wrong"
    }
  env:
    Username: $(AzureContainerRegistryUsername)
    Password: $(AzureContainerRegistryPassword)
  workingDirectory: $(workingDirectory)
  displayName: 💨 Push Chart to ACR

Important notes:

  • Helm step in Azure DevOps is somewhat weird. It contains both Helm v2 and v3 commands, so pay attention what you're about to do.
  • Octopus step templates don't understand Helm OCI-based repositories, so you have to create your own step templates.
  • Some features are still preview and may change in future.
  • Azure Container Registry authentication in Azure DevOps can be done in several ways. I've choosen to authenticate with tokens.
  • ACR does not support + in versions, but it's smart enough to replace it with _
  • az acr helm is deprecated and compatible with Helm v2 only
  • OCI images can be pushed to ACR with Helm CLI or other tools, e.g. oras
  • Sometime it is better to push Helm Charts to Octopus Feed
  • Versionsing must be SemVer 2.0 valid
comments powered by Disqus