---
url: /en/paas/artifact-generic.md
---
## Prerequisites

1. [Create Artifact Registry](/en/artifact/intro.md#create-artifact-registry)

2. [Get Artifact Registry Address](/en/artifact/intro.md#get-artifact-registry-address)

3. [Create Token](/en/artifact/intro.md#create-access-token)

## Push Artifacts

::: tabs
@tab Local Command Line Push

1. Configure .netrc to automatically load push credentials when using curl command. Replace `<CNB_TOKEN>` with actual value

```shell
printf "\nmachine \nlogin cnb\npassword %s\n" "<CNB_TOKEN>" >> ~/.netrc
```

2. Execute the following command to push to CNB. Replace `<REPO_URL>`, `<PACKAGE>`, `<VERSION>`, `<LOCAL_FILE_NAME>` with actual values

```shell
curl --netrc '<REPO_URL>/<PACKAGE>?version=<VERSION>' -T '<LOCAL_FILE_NAME>'
```

@tab Push in Cloud Native Build

1. Paste the following content to `.cnb.yaml` and commit to repository. Replace `<REPO_URL>`, `<PACKAGE>`, `<LOCAL_FILE_NAME>` with actual values

```yaml title=".cnb.yml"
$:
  tag_push:
    - docker:
        image: curlimages/curl
      stages:
       - name: "Configure Authentication Credentials"
         script: printf "machine \nlogin cnb\npassword %s\n" "${CNB_TOKEN}" > ~/.netrc
       - name: "Publish to CNB"
         script: curl --netrc "<REPO_URL>/<PACKAGE>?version=${CNB_BRANCH}" -T "<LOCAL_FILE_NAME>"
```

2. Commit a Tag, which will trigger Cloud Native Build. Note: Tag value will be used as the artifact version number, please use [Semantic Versioning](https://semver.org/)

@tab Push in Workspaces

1. Click the **"Workspaces"** button in the upper right corner of the repository page to enter the development environment

2. Execute the following command to configure credentials

```shell
printf "machine \nlogin cnb\npassword %s\n" "${CNB_TOKEN}" > ~/.netrc
```

3. Publish to CNB. Replace `<REPO_URL>`, `<PACKAGE>`, `<VERSION>`, `<LOCAL_FILE_NAME>` with actual values

```shell
curl --netrc '<REPO_URL>/<PACKAGE>?version=<VERSION>' -T '<LOCAL_FILE_NAME>'
```

:::

## Use Artifacts

### Pull Artifacts

1. Configure .netrc to automatically load push credentials when using curl command. Replace `<CNB_TOKEN>` with actual value

```shell
printf "\nmachine \nlogin cnb\npassword %s\n" "<CNB_TOKEN>" >> ~/.netrc
```

2. Pull artifacts. Replace `<REPO_URL>`, `<PACKAGE>`, `<VERSION>` with actual values

```shell
curl -OfL --netrc '<REPO_URL>/<PACKAGE>?version=<VERSION>'
```

### Delete Artifacts

generic does not provide delete command for now, please refer to [Delete Artifacts](/en/artifact/intro.md#delete-artifacts)

## FQA

### Q1: Package Name Restriction Rules

> Package name refers to the full path, for example: a/b/c.txt

1. Maximum length is 128, maximum depth is 5 levels
2. Case-sensitive. a/b/c.txt and A/B/C.TXT are different paths
3. Directory and file cannot have the same name. a/b/c and a/b/c/ cannot exist at the same time
4. Path segments cannot start or end with space. a/ b /c.txt will throw an error during parameter validation
5. Single - cannot be used as directory name or file name. a/-/c.txt is invalid
6. Package name whitelist regex is: `"^[a-zA-Z0-9\u4e00-\u9fa5._\\-/ ]+$"`
