ohpm Artifact Registry
About 546 wordsAbout 2 min
Prerequisites
Local Usage
Configure Credentials
Two methods available:
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.
ohpm config set registry <REPO_URL>
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.
registry=<REPO_URL>
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 <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.
ohpm publish <HAR_OR_TGZ_FILE> --publish_registry=<REPO_URL>Cloud Native Build
Configure Credentials
In Cloud Native Build, use the built-in environment variable CNB_TOKEN. Replace <REPO_URL> with the Artifact Registry address and <REPO_URL_SUFFIX> with the address without protocol prefix.
Other Token Methods
To use plaintext tokens, replace <YOUR_TOKEN> with your token. Or reference via a secret registry variable <ENV_NAME>. See [Using Tokens in Cloud Native Build and Development] (./intro.md#using-tokens-in-workspaces-and-cloud-native-build) for details.
Two methods available:
ohpm config set registry <REPO_URL>
ohpm config set publish_registry <REPO_URL>
ohpm config set //<REPO_URL_SUFFIX>:_auth=${CNB_TOKEN}Paste the following content into the .ohpmrc file:
registry=<REPO_URL>
publish_registry=<REPO_URL>
//<REPO_URL_SUFFIX>:_auth=${CNB_TOKEN}Pull Artifacts
ohpm install <PACKAGE_NAME>@<VERSION> --registry=<REPO_URL>Push Artifacts
ohpm publish <HAR_OR_TGZ_FILE> --publish_registry=<REPO_URL>Both operations can be integrated into the build pipeline with the following .cnb.yml examples:
main:
push:
- docker:
image: <ohpm_image>
stages:
- name: configure auth
script:
- ohpm config set registry <REPO_URL>
- ohpm config set publish_registry <REPO_URL>
- ohpm config set //<REPO_URL_SUFFIX>:_auth=${CNB_TOKEN}
- name: ohpm install
script: ohpm install <PACKAGE_NAME>@<VERSION>main:
push:
- docker:
image: <ohpm_image>
stages:
- name: configure auth
script:
- ohpm config set registry <REPO_URL>
- ohpm config set publish_registry <REPO_URL>
- ohpm config set //<REPO_URL_SUFFIX>:_auth=${CNB_TOKEN}
- name: ohpm publish
script: ohpm publish <HAR_OR_TGZ_FILE>You can also combine pull and push in a single pipeline.
Workspaces
Configure Credentials
Same as Cloud Native Build Configure Credentials
Configure Development Image
$:
vscode:
- docker:
image: <ohpm_image>Pull Artifacts
Same as Local Development Pull Artifacts
Push Artifacts
Same as Local Development Push Artifacts
More Usage
For more ohpm usage, please refer to the ohpm official documentation.