ohpm Artifact Registry
About 759 wordsAbout 3 min
Create Artifact Registry
Refer to Create Artifact Registry
Obtain Artifact Registry Address
Refer to Obtain Artifact Registry Address
Create Access Token
All resources in the Cloud Native Build platform (including repositories, Artifact Registry, OPENAPI, etc.) require an access token for operations. Create Access Token
Local Usage
Configure Credentials
Two methods are provided:
Replace <YOUR_TOKEN>
with your token, <REPO_URL>
with the Artifact Registry address, and <REPO_URL_SUFFIX>
with the Artifact Registry address without the protocol prefix.
# Example
# ohpm config set registry https://ohpm.cnb.cool/cnb/ohpm_repo/-/packages/
# ohpm config set publish_registry https://ohpm.cnb.cool/cnb/ohpm_repo/-/packages/
# ohpm config set //ohpm.cnb.cool/cnb/ohpm_repo/-/packages/:_auth=29bGg84xqRf3ZweNpYlL92e7tDv
# Configure pull repository
ohpm config set registry <REPO_URL>
# Configure push repository
ohpm config set publish_registry <REPO_URL>
ohpm config set //<REPO_URL_SUFFIX>:_auth=<YOUR_TOKEN>
Paste the following content into the .ohpmrc file in the same directory as package.json.
Replace <YOUR_TOKEN>
with your token, <REPO_URL>
with the Artifact Registry address, and <REPO_URL_SUFFIX>
with the Artifact Registry address without the protocol prefix.
# Example
# registry=https://ohpm.cnb.cool/cnb/ohpm_repo/-/packages/
# publish_registry=https://ohpm.cnb.cool/cnb/ohpm_repo/-/packages/
# //ohpm.cnb.cool/cnb/ohpm_repo/-/packages/:_auth=29bGg84xqRf3ZweNpYlL92e7tDv
# Configure pull repository
registry=<REPO_URL>
# Configure push repository
publish_registry=<REPO_URL>
//<REPO_URL_SUFFIX>:_auth=<YOUR_TOKEN>
Pull Artifacts
Use the following command to pull artifacts. Replace <PACKAGE_NAME>
, <VERSION>
, and <REPO_URL>
.
# ohpm install @pura/harmony-utils@1.3.6 --registry=https://ohpm.cnb.cool/cnb/ohpm_repo/-/packages/
ohpm install <PACKAGE_NAME>@<VERSION> --registry=<REPO_URL>
Push Artifacts
- Initialize oh-package.json5. Replace
<PACKAGE_NAME>
and<VERSION>
.
{
"name": "<PACKAGE_NAME>",
"version": "<VERSION>",
"description": "",
"main": "index.js",
"author": "",
"license": "MIT"
}
- Use the following command to publish the ohpm package. Replace
<HAR_OR_TGZ_FILE>
with the package file path and<REPO_URL>
with the Artifact Registry address.
# Example
# ohpm publish library.har --publish_registry=https://ohpm.cnb.cool/cnb/ohpm_repo/-/packages/
ohpm publish <HAR_OR_TGZ_FILE> --publish_registry=<REPO_URL>
Cloud Native Build
Configure Credentials
Cloud Native Build supports three ways to use tokens. Refer to Using Tokens in Cloud Native Build and Development. Below are the specific client usage methods:
Two methods are provided:
Replace <REPO_URL>
with the Artifact Registry address and <REPO_URL_SUFFIX>
with the Artifact Registry address without the protocol prefix.
# Example
# ohpm config set registry https://ohpm.cnb.cool/cnb/ohpm_repo/-/packages/
# ohpm config set publish_registry https://ohpm.cnb.cool/cnb/ohpm_repo/-/packages/
# ohpm config set //ohpm.cnb.cool/cnb/ohpm_repo/-/packages/:_auth=${CNB_TOKEN}
# Configure pull repository
ohpm config set registry <REPO_URL>
# Configure push repository
ohpm config set publish_registry <REPO_URL>
# Method 1: Use CNB_TOKEN
ohpm config set //<REPO_URL_SUFFIX>:_auth=${CNB_TOKEN}
# Method 2: Directly use, replace <YOUR_TOKEN> with your token
# ohpm config set //<REPO_URL_SUFFIX>:_auth=<YOUR_TOKEN>
# Method 3: Secret Registry, replace <ENV_NAME> with your secret registry variable
# ohpm config set //<REPO_URL_SUFFIX>:_auth=${<ENV_NAME>}
Paste the following content into the .ohpmrc file. Replace <REPO_URL>
with the Artifact Registry address and <REPO_URL_SUFFIX>
with the Artifact Registry address without the protocol prefix.
# Example
# registry=https://ohpm.cnb.cool/cnb/ohpm_repo/-/packages/
# publish_registry=https://ohpm.cnb.cool/cnb/ohpm_repo/-/packages/
# //ohpm.cnb.cool/cnb/ohpm_repo/-/packages/:_auth=29bGg84xqRf3ZweNpYlL92e7tDv
# Configure pull repository
registry=<REPO_URL>
# Configure push repository
publish_registry=<REPO_URL>
# Method 1: Use CNB_TOKEN
//<REPO_URL_SUFFIX>:_auth=${CNB_TOKEN}
# Method 2: Directly use, replace <YOUR_TOKEN> with your token
# //<REPO_URL_SUFFIX>:_auth=<YOUR_TOKEN>
# Method 3: Secret Registry, replace <ENV_NAME> with your secret registry variable
# //<REPO_URL_SUFFIX>:_auth=${<ENV_NAME>}
Pull Artifacts
Replace <PACKAGE_NAME>
, <VERSION>
, <REPO_URL>
with the Artifact Registry address, and <REPO_URL_SUFFIX>
with the Artifact Registry address without the protocol prefix.
main:
push:
- docker:
image: <ohpm_image> # Use your own ohpm image
stages:
- name: ohpm install
script:
# If using command-line setup, include the following two lines. Not needed for configuration file setup.
- ohpm config set registry <REPO_URL>
- ohpm config set //<REPO_URL_SUFFIX>:_auth=${CNB_TOKEN}
- ohpm install <PACKAGE_NAME>@<VERSION> --registry=<REPO_URL>
Push Artifacts
Replace <HAR_OR_TGZ_FILE>
with the package file path, <REPO_URL>
with the Artifact Registry address, and <REPO_URL_SUFFIX>
with the Artifact Registry address without the protocol prefix.
main:
push:
- docker:
image: <ohpm_image> # Use your own ohpm image
stages:
- name: ohpm publish
script:
# If using command-line setup, include the following two lines. Not needed for configuration file setup.
- ohpm config set publish_registry <REPO_URL>
- ohpm config set //<REPO_URL_SUFFIX>:_auth=${CNB_TOKEN}
- ohpm publish <HAR_OR_TGZ_FILE> --publish_registry=<REPO_URL>
Workspaces
Configure Credentials
Same as Cloud Native Build Configure Credentials
Configure Development Image
$:
vscode:
- docker:
image: <ohpm_image> # Use your own ohpm image
Pull Artifacts
Same as Local Development Pull Artifacts
Push Artifacts
Same as Local Development Push Artifacts
More Usage
For more ohpm usage, refer to the official ohpm documentation.