---
url: /en/artifact/helm.md
---
## Login to CNB Helm Artifact Registry

CNB Helm only supports Helm artifacts in OCI format. It is recommended to use Helm v3.8.0 or above. For details, please refer to the Helm documentation.

You can use CNB access token as login credentials. For how to get `CNB_TOKEN`, please refer to [Creating an Access Token](./intro.md#creating-an-access-token). Login command:

```bash
helm registry login helm.cnb.share.ralphlauren.cn -u cnb -p <YOUR_TOKEN>
```

## Helm Artifact Path Rules

When publishing artifacts to a repository, two naming rules are supported:

1. Same-name artifacts - Artifact path matches repository path, e.g.: `helm.cnb.share.ralphlauren.cn/${CNB_REPO_SLUG_LOWERCASE}`
2. Different-name artifacts - Repository path serves as namespace for artifacts, artifact path = repository path/artifact name, e.g.: `helm.cnb.share.ralphlauren.cn/${CNB_REPO_SLUG_LOWERCASE}/<ARTIFACT_NAME>`

Note: When using helm push remote, the chart name does not appear in the remote-url, but is read from the chart.

Therefore, for same-name artifacts, the remote-url is `helm.cnb.share.ralphlauren.cn/${CNB_GROUP_SLUG_LOWERCASE}`, and for different-name artifacts, the remote-url is `helm.cnb.share.ralphlauren.cn/${CNB_REPO_SLUG_LOWERCASE}`.

## Pushing Artifacts

### Local Push

Same-name artifacts

```bash
# chart name must match repository name
helm package chart-path
helm push chartname-version.tgz oci://helm.cnb.share.ralphlauren.cn/${CNB_GROUP_SLUG_LOWERCASE}
```

Different-name artifacts

```bash
helm package chart-path
helm push chartname-version.tgz oci://helm.cnb.share.ralphlauren.cn/${CNB_REPO_SLUG_LOWERCASE}
```

### Push in Cloud Native Build

```yaml title=".cnb.yml"
main:
  push:
    - docker:
        image: alpine/helm
      stages:
        - name: helm login
          script: helm registry login -u ${CNB_TOKEN_USER_NAME} -p "${CNB_TOKEN}" ${CNB_HELM_REGISTRY}
        - name: helm package
          script: helm package ${YOUR_CHART_PATH}
        - name: helm push
          script: helm push oci://${CNB_HELM_REGISTRY}/${CNB_GROUP_SLUG_LOWERCASE}
```

### Push in Workspaces

Same-name artifacts

```bash
# chart name must match repository name
helm package ${YOUR_CHART_PATH}
helm push chartname-version.tgz oci://helm.cnb.share.ralphlauren.cn/${CNB_GROUP_SLUG_LOWERCASE}
```

Different-name artifacts

```bash
helm package ${YOUR_CHART_PATH}
helm push chartname-version.tgz oci://helm.cnb.share.ralphlauren.cn/${CNB_REPO_SLUG_LOWERCASE}
```

## Using Artifacts

### Pull from Local Command Line

```bash
helm pull oci://helm.cnb.share.ralphlauren.cn/<ARTIFACT_PATH> --version <VERSION>

# ...
```

### Other Common Commands

#### View Helm Information

```bash
helm show all oci://helm.cnb.share.ralphlauren.cn/<ARTIFACT_PATH> --version <VERSION>
```

#### Preview Manifest

```bash
helm template <RELEASE_NAME> oci://helm.cnb.share.ralphlauren.cn/<ARTIFACT_PATH> --version <VERSION>
```

#### Install Helm Chart

```bash
helm install <RELEASE_NAME> oci://helm.cnb.share.ralphlauren.cn/<ARTIFACT_PATH> --version <VERSION>
```

#### Upgrade Helm Chart

```bash
helm upgrade <RELEASE_NAME> oci://helm.cnb.share.ralphlauren.cn/<ARTIFACT_PATH> --version <VERSION>
```

## More Usage

For more Helm usage, please refer to the official documentation
