Generic Artifact Registry
About 417 wordsAbout 1 min
Prerequisites
Push Artifacts
Credential Setup
Before pushing or pulling artifacts, configure .netrc authentication credentials (one-time setup):
printf "machine generic.cnbprod.alpha.qq.com\nlogin cnb\npassword %s\n" "${CNB_TOKEN}" > ~/.netrcFor how to obtain CNB_TOKEN, refer to Creating an Access Token.
Local Command Line Push
After configuring credentials, run the following command to push artifacts (replace <REPO_URL>, <PACKAGE>, <VERSION>, <LOCAL_FILE_NAME> with actual values):
curl --netrc '<REPO_URL>/<PACKAGE>?version=<VERSION>' -T '<LOCAL_FILE_NAME>'Push in Cloud Native Build
- Add the following content to
.cnb.ymland commit to your repository. Push a Tag to trigger the build; the Tag value will be used as the artifact version:
$:
tag_push:
- docker:
image: curlimages/curl
stages:
- name: setup netrc
script: printf "machine generic.cnbprod.alpha.qq.com\nlogin cnb\npassword %s\n" "${CNB_TOKEN}" > ~/.netrc
- name: upload
script: curl --netrc "<REPO_URL>/<PACKAGE>?version=${CNB_BRANCH}" -T "<LOCAL_FILE_NAME>"Replace
<REPO_URL>,<PACKAGE>,<LOCAL_FILE_NAME>with actual values. It is recommended to use Semantic Versioning.
Push in Workspaces
- Click the "Workspaces" button in the upper right corner of the repository page to enter the development environment
- After configuring credentials, run the push command (same as Local Command Line Push):
curl --netrc '<REPO_URL>/<PACKAGE>?version=<VERSION>' -T '<LOCAL_FILE_NAME>'Use Artifacts
Pull Artifacts
If .netrc credentials are already configured (see tip in Push Artifacts section above), pull directly:
curl -OfL --netrc '<REPO_URL>/<PACKAGE>?version=<VERSION>'(replace <REPO_URL>, <PACKAGE>, <VERSION> with actual values)
Delete Artifacts
Generic artifact registry does not support command-line deletion yet. Please refer to Delete Artifacts.
FAQ
Q1: Package Name Restriction Rules
Package name refers to the full path, for example
a/b/c.txt.
- Maximum length is 128 characters, with a maximum depth of 5 levels
- Case-sensitive:
a/b/c.txtandA/B/C.TXTare different paths - Directory and file cannot share the same name:
a/b/canda/b/c/cannot coexist - Path segments cannot start or end with spaces
- A single
-cannot be used as a directory or file name - Package name characters must match the regex:
^[a-zA-Z0-9\u4e00-\u9fa5._\\-/ ]+$